public interface FileObject
在这个接口的所有方法可能如果发生安全异常抛出SecurityException。
除非明确允许,在这个接口的所有方法可能如果null论点抛出一个NullPointerException。
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete()
删除此文件对象。
|
CharSequence |
getCharContent(boolean ignoreEncodingErrors)
获取此文件对象的字符内容,如果可用的话。
|
long |
getLastModified()
获取此文件对象的上次修改的时间。
|
String |
getName()
获取此文件对象的一个用户友好的名称。
|
InputStream |
openInputStream()
获取此文件对象InputStream。
|
OutputStream |
openOutputStream()
获取此文件的输出流对象。
|
Reader |
openReader(boolean ignoreEncodingErrors)
获取此对象的读者。
|
Writer |
openWriter()
获取此文件对象的一个写作者。
|
URI |
toUri()
返回一个URI标识该文件对象。
|
URI toUri()
String getName()
"BobsApp\Test.java"在命令行上,这种方法应该返回
"BobsApp\Test.java"而
toUri方法可能返回
file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java。
InputStream openInputStream() throws IOException
IllegalStateException -如果该文件对象打开了写作和不支持读取
UnsupportedOperationException -如果这类文件对象不支持字节访问
IOException如果发生I/O错误
OutputStream openOutputStream() throws IOException
IllegalStateException -如果该文件对象被打开阅读和写作不支持
UnsupportedOperationException -如果这类文件对象不支持字节访问
IOException如果发生I/O错误
Reader openReader(boolean ignoreEncodingErrors) throws IOException
ignoreEncodingErrors是真实的。
ignoreEncodingErrors忽略编码错误如果真的
IllegalStateException -如果该文件对象打开了写作和不支持读取
UnsupportedOperationException -如果这类文件对象不支持字符访问
IOException如果发生I/O错误
CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException
ignoreEncodingErrors报道除非是真的。
ignoreEncodingErrors忽略编码错误如果真的
null否则
IllegalStateException -如果该文件对象打开了写作和不支持读取
UnsupportedOperationException -如果这类文件对象不支持字符访问
IOException如果发生I/O错误
Writer openWriter() throws IOException
IllegalStateException -如果该文件对象被打开阅读和写作不支持
UnsupportedOperationException -如果这类文件对象不支持字符访问
IOException如果发生I/O错误
long getLastModified()
boolean delete()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.