I'm trying to create an empty .properties file on my filesystem using java.io.File.
My code is:
File newFile = new File(new File(".").getAbsolutePath() + "folder\\" + newFileName.getText() + ".properties");
if (newFile.createNewFile()){
//do sth...
}
It says that it's impossible to find the specified path. Printing the Files's constructor's argument it shows correctly the absolute path.
What's wrong?
new File("folder", newFileName.getText() + ".properties")and it will store the file in thefolderdirectory relative to your current location; 2. Make sure the path exists, as it will not be created for you bycreateNewFile(you can usenewFile.getParentFile().mkdirs())new File(".").getAbsolutePath() + "folder\\"doesn't have a separator between the "." and "folder", so you end up with ".folder" instead (filling in for the absolute path instead of ".", but you get the idea)