java – FileInputStream如何获取File的内容?
发布时间:2020-12-15 02:50:55 所属栏目:Java 来源:网络整理
导读:我有一个文件f,我需要将它影响到FileInputStream fs: File f = new File("C:/dir/foo.txt");FileInputStream fs = (FileInputStream)f; 但我得到这个错误: Cannot cast from File to FileInputStream fs如何获得f的内容? 解决方法 诀窍是: FileInputStre
我有一个文件f,我需要将它影响到FileInputStream fs:
File f = new File("C:/dir/foo.txt"); FileInputStream fs = (FileInputStream)f; 但我得到这个错误: Cannot cast from File to FileInputStream fs如何获得f的内容? 解决方法
诀窍是:
FileInputStream fs = new FileInputStream(f); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |