Skip to content
Sign upLog in
← Back to Community

Can you create files locally in Java (nio) using

Profile icon

Previously we were attempting to get the local user, but only returning "Runner," due to being on the cloud and not local. So, we kind of ignore that line for now. In location we have manually set the file location to the userName we would be hoping to return but, did not "josparso." Then, we create a new Path location based on the String location. Lastly, we try to createFile and catch any errors. At the moment this method is not working to create files locally on the machine. Does the community have any better suggestions on how to create files locally using

Link to code:

public class NewFile{

String userName = System.getProperty("");
String location = "C://Temp//Users//josparso//TBA//TBASave.txt";

Path newFilePath = Paths.get(location);

public void createNewFile(){
}catch(IOException e){}

Profile icon
Profile icon