FileInputStream如何获取File的内容? [英] How can a FileInputStream get the content of File?
本文介绍了FileInputStream如何获取File的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件 f
,我需要将它影响到 FileInputStream
fs
:
档案f =新档案(C:/dir/foo.txt);
FileInputStream fs =(FileInputStream)f;
但是我得到这个错误:
无法从File转换到FileInputStream
fs
获取 f
?
解决方案
pre $ FileInputStream fs = new FileInputStream(f);
I have a file f
and I need to affect it into a FileInputStream
fs
:
File f = new File("C:/dir/foo.txt");
FileInputStream fs = (FileInputStream)f;
But i get this error :
Cannot cast from File to FileInputStream
How can fs
get the content of f
?
解决方案
The trick is this:
FileInputStream fs = new FileInputStream(f);
这篇关于FileInputStream如何获取File的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文