色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

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

java 文件的縮進排版

瀏覽:109日期: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
相關文章:
主站蜘蛛池模板: 久久久国产99久久国产首页 | 亚洲综合一区二区精品久久 | a免费视频| 欧美日韩中文一区二区三区 | 69xx欧美| 久久一日本道色综合久 | 亚洲人成网国产最新在线 | 日韩午夜精品 | 日韩一区二区三区免费视频 | 深夜国产成人福利在线观看女同 | 99精品视频在线观看免费播放 | 欧美一区二区三区视视频 | 伊人久色 | 久久黄色一级视频 | 国产一区在线观看免费 | 国产精品观看 | 久久精品福利视频在线观看 | 精品久久久久久久久免费影院 | 免费一级欧美大片久久网 | 自拍偷在线精品自拍偷无码专区 | 在线观看人成午夜影片 | 午夜神马理论 | 亚洲悠悠色综合中文字幕 | 日本一级毛片视频无遮挡免费 | 久久精品视频网站 | 爱爱爱久久久久久久 | 国产精品视频久久久 | 毛片国产 | 国产欧美精品综合一区 | 91视频18| 久久香蕉国产精品一区二区三 | 欧美1区二区三区公司 | 九九九九精品视频在线播放 | 欧美无极品| 国产一区不卡 | 3至13呦女毛片 | 成人首页| 欧美第一页草草影院浮力 | 99在线视频播放 | 亚洲欧美日韩综合二区三区 | 97在线免费观看视频 |