private static List<String> getLines(File file) {
try {
return Files.readAllLines(file.toPath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private static writeFile(List<String> strings){
File wFile = new File("xxx");
if(!file.exists()){
wFile.createNewFile();
}else{
wFile.delete();
wFile.createNewFile();
}
Files.write(wFile.toPath(), strings);
}
NIO Demo
最新推荐文章于 2022-11-09 19:14:33 发布