如何检查来自 SmbFile 的流是否已准备好读取?
How to check if a stream from an SmbFile is ready to be read?
这段代码的等价物是什么:
FileReader reader = null;
try
{
reader = new FileReader( file);
return reader.ready();
}
catch( IOException ex)
{
return false;
}
为了SmbFile
?我试过了:
BufferedReader reader = null;
try
{
SmbFileInputStream fstream = new SmbFileInputStream( file);
reader = new BufferedReader( new InputStreamReader( fstream));
return reader.ready();
}
catch( IOException ex)
{
return false;
}
但我总是得到 "false" 作为结果。
根据文档看来,不能保证此标志无法读取,Note that returning false does not guarantee that the next read will block.
你可以尝试这种方式来避免空值,
String line;
while((line = br.readLine()) != null) {
System.out.println(line);
}
你也可以看看这个post,bufferedreader-not-stating-ready-when-it-should
希望对您有所帮助
这段代码的等价物是什么:
FileReader reader = null;
try
{
reader = new FileReader( file);
return reader.ready();
}
catch( IOException ex)
{
return false;
}
为了SmbFile
?我试过了:
BufferedReader reader = null;
try
{
SmbFileInputStream fstream = new SmbFileInputStream( file);
reader = new BufferedReader( new InputStreamReader( fstream));
return reader.ready();
}
catch( IOException ex)
{
return false;
}
但我总是得到 "false" 作为结果。
根据文档看来,不能保证此标志无法读取,Note that returning false does not guarantee that the next read will block.
你可以尝试这种方式来避免空值,
String line;
while((line = br.readLine()) != null) {
System.out.println(line);
}
你也可以看看这个post,bufferedreader-not-stating-ready-when-it-should
希望对您有所帮助