我有一个文件f
,我需要将其影响到FileInputStream
fs
:
File f = new File("C:/dir/foo.txt");
FileInputStream fs = (FileInputStream)f;
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
Cannot cast from File to FileInputStream
Run Code Online (Sandbox Code Playgroud)
怎么能fs
得到的内容f
?
A.H*_*.H. 14
诀窍是:
FileInputStream fs = new FileInputStream(f);
Run Code Online (Sandbox Code Playgroud)