Skip to content
Sign upLog in
← Back to Community

Can you create files locally in Java (nio) using Repl.it?

Profile icon
Zeune

Previously we were attempting to get the local user, but only returning "Runner," due to repl.it 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 repl.it?

Link to code: https://repl.it/@Zeune/TBA

[code]
public class NewFile{

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

Path newFilePath = Paths.get(location);

public void createNewFile(){
try{
Files.createFile(newFilePath);
}catch(IOException e){}
}
}[/code]

Voters
Profile icon
AlainOmond
Profile icon
Zeune