public class test7 {
public static void main(String[] args){
BufferedReader br = null;
try {
br = new BufferedReader(
new InputStreamReader(
new FileInputStream("这里是文件名")));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
String line = null;
try {
line = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
String[] test;
int lineNo = 1;
while(line!=null){
test = line.split(":");
System.out.println("line"+lineNo+test[test.length - 1]);
lineNo ++;
}
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
最后输出的是第一行最后一个:后面的内容,然后line不断增加,line数也对,就是后面内容一直是第一行的。
求大家帮个忙呗!谢谢了!
winter_yi
Code_M0keny
相关分类