午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

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

java 文件的縮進排版

瀏覽:217日期: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
相關文章:
主站蜘蛛池模板: 二级黄色片 | 久久免费手机视频 | 国产在线一区视频 | 亚洲天堂中文在线 | 中文字幕永久在线 | 欧美精品18| 综合99| 91在线成人 | 五月天久久久久 | 精品一区二区三区在线视频 | 精品一区二区三区日韩 | 欧美成人精品一区二区三区在线看 | 第一页在线观看 | www欧美视频 | 日韩一二三区在线观看 | 91香蕉国产在线观看软件 | 成人手机在线视频 | 国产精品2018 | 免费又黄又爽又色的视频 | 国产激情片 | 午夜av免费在线观看 | 亚洲日本免费 | 亚洲va欧美va天堂v国产综合 | 午夜婷婷网 | 少妇伊人 | 亚洲黄色av | 欧美日本日韩 | 日韩av免费播放 | 成人精品国产 | 久久五十路 | 欧美精品亚洲精品 | 四虎在线影院 | 一级免费黄色片 | 精品999www| 免费在线毛片 | 英国xxxⅹ性hd极品 | 久久99精品久久久久久国产越南 | 日韩中文字幕免费视频 | 亚洲一级av毛片 | 婷婷狠狠干 | 亚洲激情欧美激情 |