How to create a file in java without a extension
Is it pos开发者_开发知识库sible in java to create a file without extension
You can try
File f;
f=new File("myfile");
if(!f.exists()){
f.createNewFile();
}
Yes, it's easy. No different then doing it with an extension. So for example, if you have a string you want to write to a file, you can do
FileOutputStream out = new FileOutputStream("noExtension");
PrintStream printout = new PrintStream(out);
printout.println("Hello world!");
printout.close();
You could skip the PrintStream and do out.write("Hello world!".getBytes());
if you wanted.
精彩评论