Can I get the associated file out of a FileInputStream or a FileOutputStream? I want to tell if they are pointing to the same file. But basically I want to see if I can get a reference to the File that belongs to the FileInputStream or FileOutputStream. Is there a class like that I can use? Or can I get it out of FileInputStream or FileOutputStream?
问问题
132 次
1 回答
4
这就是我所做的:
public class FileAwareFileInputStream extends FileInputStream {
private File file;
public FileAwareFileInputStream(File file) throws FileNotFoundException {
super(file);
this.file = file;
}
public File getFile() {
return this.file;
}
}
FileOutputStream 也是如此。
于 2013-07-31T16:53:52.057 回答