FileInputStream fstream = new FileInputStream("data.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null)
{
//Test if it is a line we need
if(strLine.charAt(0) != ' ' && strLine.charAt(5) == ' '
&& strLine.charAt(10) == ' ' && strLine.charAt(15) == ' '
&& strLine.charAt(20) == ' ' && strLine.charAt(25) == ' ')
{
System.out.println (strLine);
}
}
我正在閱讀一個文件中有空白行(不僅是空白)和比較特定索引的字符以查看我是否需要該行,但是當我讀取一行空白時我得到一個字符串索引超出範圍。Java readline空白
你能提供一些代碼來說明你的問題嗎? – 2012-02-10 04:39:52
需要看一些代碼來幫助你... – debracey 2012-02-10 04:40:16