我想这听起来很疯狂,但我正在从一个文件中读取,而且它似乎跳过了文件的第一行。为什么用BufferedReader读取文件注释的第一行?
这是怎么回事?
这里是源:
private void loadFile(String fileNPath)
{
StringBuilder currentFileContents = new StringBuilder();
CharBuffer contentsBuffer = CharBuffer.allocate(65536);
int status=0;
try
{
BufferedReader in = new BufferedReader(new FileReader(fileNPath));
while(status!=-1)
{
status=in.read(contentsBuffer);
currentFileContents.append(contentsBuffer);
contentsBuffer.clear();
}
System.out.println(currentFileContents.toString());
}
catch(FileNotFoundException n)
{
//Should be imposible
}
catch(IOException n)
{
n.printStackTrace(System.out);
}
}
它必须是什么我俯瞰。
我复制并粘贴确切的来源,所以我希望这也发生在你身上。
感谢, caalip
我只拿到文件的第二行,然后。 – 2011-05-01 22:02:27