//以下是我做的java 文件的縮進排版
//不管怎麼說
import java
import java
import java
import lang
import lang
import util
class DentJavaCode
{
public static boolean dent(File file
{
String as[] = new String[
if(file == null || !file
{
return false;
} else
{
as = py(file
ArrayList arraylist = new ArrayList();
dent(as
as = (String[])arraylist
out
py(as
return true;
}
}
public static int dent(ArrayList arraylist
{
if(arraylist == null && arraylist
{
System
return i;
}
if(arraylist
{
System
return i;
} else
{
String as[] = new String[
as = (String[])arraylist
return dent(as
}
}
public static String[] dent(String as[]
{
ArrayList arraylist = new ArrayList();
dent(as
if(as
as
return (String[])arraylist
}
public static int dent(String as[]
{
int j = as
boolean flag = false;
if(as == null || as
{
System
return i;
}
if(arraylist == null)
{
System
return i;
}
for(int l =
{
if(as[l] == null)
continue;
as[l] = as[l].trim();
int k = as[l].length();
if(k == 0)
continue;
int i1 = Str9.indexOf_outQuotes(special, as[l]);
if(i1 < 0)
{
if(flag)
arraylist.add(space(2) + as[l]);
else
arraylist.add(space(i) + as[l]);
continue;
}
String s = as[l].substring(i1);
if(s.indexOf("{") == 0)
s = "{";
else
if(s.indexOf("}") == 0)
s = "}";
else
if(s.indexOf("//") == 0)
s = "//";
else
if(s.indexOf("*/") == 0)
s = "*/";
else
if(s.indexOf("/*") == 0)
s = "/*";
if(s.equals("//"))
{
if(i1 > 0)
{
arraylist.add(space(i) + as[l].substring(0, i1));
arraylist.add(space(i) + as[l].substring(i1));
} else
{
arraylist.add(space(i) + as[l]);
}
continue;
}
if(s.equals("*/"))
{
flag = false;
if(i1 >
arraylist
arraylist
i
if(k > i
{
as[l] = as[l]
l
}
continue;
}
if(s
{
flag = true;
if(i
{
arraylist
as[l] = as[l]
}
if((i
{
flag = false;
i
arraylist
if(as[l]
{
as[l] = as[l]
l
}
continue;
}
if(as[l]
continue;
arraylist
as[l] = as[l]
if(as[l]
arraylist
continue;
}
if(s
{
i
if(as[l]
{
arraylist
i += increment;
continue;
}
arraylist
i += increment;
if(k > i
{
as[l] = as[l]
l
}
continue;
}
if(s
{
arraylist
i
i
if(k > i
{
arraylist
i
if(k > i
{
as[l] = as[l]
l
}
continue;
}
if(as[l]
{
System
arraylist
continue;
}
arraylist
if(k > i
{
as[l] = as[l]
l
}
} else
{
arraylist
}
}
return i;
}
static String space(int i)
{
return Str
}
public DentJavaCode(File file)
{
String as[] = null;
as = py(file
ArrayList arraylist = new ArrayList();
dent(as
String s = file
int i =
boolean flag = false;
File file
file
i =
do
{
if(i >=
break;
file
if(!file
break;
i++;
} while(true);
if(file
file
if(file
{
String as
py(as
System
} else
{
System
}
}
public static void main(String args[])
{
String args
File file = new File(args[
args
ArrayList arraylist = new ArrayList();
dent(args
File file
int i =
do
{
if(i >=
break;
file
if(!file
break;
i++;
} while(true);
if(file
file
String args
if(file
{
py(args
System
} else
{
System
}
}
static int increment =
public static String special[] = {
};
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19308.html