public native boolean createFileExclusively(String path)
throws IOException;
ls -al www.flydean.com
-rw-r--r-- 1 flydean staff 15 May 14 15:43 www.flydean.com
chmod 600 www.flydean.com
public void createFileWithFile() throws IOException {
File file = new File("file/src/main/resources/www.flydean.com");
//Create the file
if (file.createNewFile()){
log.info("恭喜,文件创建成功");
}else{
log.info("不好意思,文件创建失败");
}
//Write Content
try(FileWriter writer = new FileWriter(file)){
writer.write("www.flydean.com");
}
}
public void createFileWithStream() throws IOException
{
String data = "www.flydean.com";
try(FileOutputStream out = new FileOutputStream("file/src/main/resources/www.flydean.com")){
out.write(data.getBytes());
}
}