java 将读入的文件的一段截取下来并保存时出现nullpointerexception
夜半歌声丶 2017-11-24 09:42:58 public String[] read()
{
try {
String path="data.txt";
File f=new File(path);
InputStreamReader reader= new InputStreamReader(new FileInputStream(f));
BufferedReader br=new BufferedReader(reader);
String line="";
String[] s=new String[36801];
int n=0;
line=br.readLine();
while(line!=null)
{
line=br.readLine();
s[n]=line.substring(41,45);
System.out.print(s[n]+" ");
n++;
}
br.close();
return s;
}catch (IOException e) {
e.printStackTrace();
}
return null;
}
下面读的文件 中的其中一行2011:08:03:00:00:05:687: C1 1273 60001 1277 2947 6625 3 6 1277 1269 1272 1348 1375 1182 0 0 0 0