public static void main(String[] args){ BufferedReader br = null; try { br = new BufferedReader( new InputStreamReader( new FileInputStream("一个txt文件"))); } catch (FileNotFoundException e) { e.printStackTrace(); } String line = null; try { line = br.readLine(); } catch (IOException e) { e.printStackTrace(); } String[] appName; int lineNo = 1; while (line != null) { appName = line.split("\\["); String[] APP; String app = appName.toString(); if(appName != null) { APP = app.split("\\]"); System.out.println("Line" + lineNo + " " + APP[0]); lineNo ++; } try { line = br.readLine(); } catch (IOException e) { e.printStackTrace(); } } try { br.close(); } catch (IOException e) { e.printStackTrace(); }}txt文件里面是:我爱[慕]课网我爱j[ava]我[爱]编程运行结果是:Line1 [Ljava.lang.String;@3cd1a2f1Line2 [Ljava.lang.String;@2f0e140bLine3 [Ljava.lang.String;@7440e464求各路大神解答,拜托了!
添加回答
举报
0/150
提交
取消