/** *//**读文件
* @param path
* @return
* @throws IOException
*/
public String FileInputStreamDemo(String path) throws IOException...{
File file=new File(path);
if(!file.exists()||file.isDirectory())
throw new FileNotFoundException();
FileInputStream fis=new FileInputStream(file);
byte[] buf = new byte[1024];
StringBuffer sb=new StringBuffer();
while((fis.read(buf))!=-1)...{
sb.append(new String(buf));
buf=new byte[1024];//重新生成,避免和上次读取的数据重复
}
return sb.toString();
}
FileInputStream读取文件
最新推荐文章于 2024-08-14 11:38:52 发布