public static void readFile(String path){
File file = new File(path);
if( !file.exists()){
return;
}
try {
FileInputStream fis=new FileInputStream(file);
byte []buffer = new byte[1024];
int len = 0;
ByteArrayOutputStream out = new ByteArrayOutputStream();
while((len = fis.read(buffer)) != -1){
out.write(buffer, 0, len);
}
fis.close();
out.close();
System.out.println(new String(out.toByteArray()));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Java文件读写
最新推荐文章于 2023-04-18 19:25:35 发布