亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

java 文件的縮進排版

瀏覽:97日期:2024-06-11 18:21:18
內容: //以下是我做的java 文件的縮進排版,算法有缺點.但能用,//不管怎么說,排java文件時比UltralEdit的排版強。import java.io.File;import java.io.PrintStream;import java.util.ArrayList;import lang9.Str9;import lang9.out;import util9.Load9;class DentJavaCode{ public static boolean dent(File file, File file1) { String as[] = new String[1]; if(file == null || !file.exists()) { return false; } else { as = Load9.copy(file, as); ArrayList arraylist = new ArrayList(); dent(as, arraylist, 0); as = (String[])arraylist.toArray(as); out.b('s.len=' + as.length); Load9.copy(as, file1); return true; } } public static int dent(ArrayList arraylist, ArrayList arraylist1, int i) { if(arraylist == null && arraylist.size() == 0) { System.out.println('dent frm list1,but list1 isnull'); return i; } if(arraylist1 == null) { System.out.println('dent to list2,but list2 is null'); return i; } else { String as[] = new String[1]; as = (String[])arraylist.toArray(as); return dent(as, arraylist1, i); } } public static String[] dent(String as[], String as1[], int i) { ArrayList arraylist = new ArrayList(); dent(as, arraylist, i); if(as1 == null) as1 = new String[1]; return (String[])arraylist.toArray(as1); } public static int dent(String as[], ArrayList arraylist, int i) { int j = as.length; boolean flag = false; if(as == null || as.length == 0) { System.out.println('dent from s[],but s[] is null'); return i; } if(arraylist == null) { System.out.println('dent to list,but list is null'); return i; } for(int l = 0; l < as.length; 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> 0) arraylist.add(space(2) + as[l].substring(0, i1)); arraylist.add('*/'); i1 += 2; if(k> i1) { as[l] = as[l].substring(i1); l--; } continue; } if(s.equals('/*')) { flag = true; if(i1> 0) { arraylist.add(space(i) + as[l].substring(0, i1)); as[l] = as[l].substring(i1); } if((i1 = Str9.indexOf_outQuotes('*/', as[l], i1 + 2)) != -1) { flag = false; i1 += 2; arraylist.add(as[l].substring(0, i1)); if(as[l].length()> i1) { as[l] = as[l].substring(i1); l--; } continue; } if(as[l].length() 0) arraylist.add(space(2) + as[l]); continue; } if(s.equals('{')) { i1++; if(as[l].indexOf('//') == i1) { arraylist.add(space(i) + as[l]); i += increment; continue; } arraylist.add(space(i) + as[l].substring(0, i1)); i += increment; if(k> i1) { as[l] = as[l].substring(i1); l--; } continue; } if(s.equals('}')) { arraylist.add(space(i) + as[l].substring(0, i1)); i -= increment; i1++; if(k> i1 && as[l].charAt(i1) == ';') { arraylist.add(space(i) + '};'); i1++; if(k> i1) { as[l] = as[l].substring(i1); l--; } continue; } if(as[l].indexOf('}//') == 0) { System.out.println('2s[i]=' + as[l] + ',indent=' + i); arraylist.add(space(i) + as[l]); continue; } arraylist.add(space(i) + '}'); if(k> i1) { as[l] = as[l].substring(i1); l--; } } else { arraylist.add(space(i) + as[l]); } } return i; } static String space(int i) { return Str9.repeat(' ', i); } public DentJavaCode(File file) { String as[] = null; as = Load9.copy(file, as); ArrayList arraylist = new ArrayList(); dent(as, arraylist, 0); String s = file.getName(); int i = 0; boolean flag = false; File file1; file1 = file1 = new File(s + 'dent0'); i = 1; do { if(i>= 5) break; file1 = new File(s + 'dent' + i); if(!file1.exists()) break; i++; } while(true); if(file1.exists()) file1.delete(); if(file.renameTo(file1)) { String as1[] = (String[])arraylist.toArray(as); Load9.copy(as1, file); System.out.println('ok'); } else { System.out.println('rename:false'); } } public static void main(String args[]) { String args1[] = new String[1]; File file = new File(args[0]); args1 = Load9.copy(file, args1); ArrayList arraylist = new ArrayList(); dent(args1, arraylist, 0); File file1 = new File(args[0] + 'dent0'); int i = 1; do { if(i>= 5) break; file1 = new File(args[0] + 'dent' + i); if(!file1.exists()) break; i++; } while(true); if(file1.exists()) file1.delete(); String args2[] = (String[])arraylist.toArray(args1); if(file.renameTo(file1)) { Load9.copy(args2, file); System.out.println('ok'); } else { System.out.println('rename:false'); } } static int increment = 3; public static String special[] = { '{', '}', '//', '/*', '*/' };} Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp, scjd //以下?
標簽: Java
相關文章:
主站蜘蛛池模板: 日韩黄色片在线观看 | 国产精品视频公开费视频 | 欧美欧美aaaaa一级毛片 | 中文字幕日韩一区 | 国产a级免费 | 国产精品美女福利视频一区 | 久久精品成人一区二区三区 | 未满十八18周岁禁止免费国产 | 打电话系列国产在线 | 337p日本大胆 | 国产成人v爽在线免播放观看 | 高清不卡毛片免费观看 | 成人在线免费观看视频 | 鲁丝丝国产一区二区 | 亚洲国产婷婷香蕉久久久久久 | 中文字幕亚洲不卡在线亚瑟 | 亚洲精品99久久久久中文字幕 | 国产成人免费片在线观看 | 在线观看永久免费视频网站 | 久久只有这才是精品99 | 永久免费影院 | 在线播放黄色片 | 国产一区二区精品久久凹凸 | 久久精品国产99国产精品亚洲 | 欧美日中文字幕 | 真实国产乱子伦对白视频37p | 亚洲线精品一区二区三区 | 黄免费视频 | 特级毛片aaaa免费观看 | 亚洲一区二区三区播放在线 | 国产麻豆免费视频 | 精品一久久 | 黄色在线免费观看 | 国产爽妇网 | 精品一区二区久久 | 亚洲视频在线观看网址 | 同性男男黄h片在线播放免费 | 一级久久 | 国产大片线上免费看 | 精品一区二区影院在线 | 中国一级黄色片子 |