代码很简单如下:
public static void createFile(String filePath) throws IOException {
FileOutputStream out=null;
try {
out = new FileOutputStream(new File(filePath));
System.out.println("创建文件成功!");
} catch (FileNotFoundException e) {
e.printStackTrace();
}finally{
out.close();
}
}
我想要这样效果:本来这样就可以成功创建一个文件,但文件编码格式不是我想要的(好像windows系统 默认 US-ASCII 编码格式保存文件)能不能在程序指定文件保存的编码格式,例如:utf-8 ,文件自动就以utf-8编码保存了。