how to write file to particular directory in java code example
Example 1: java create file in folder
File file = new File("src/resources/run.txt");
file.getParentFile().mkdirs();
file.createNewFile();
Example 2: creating file in specific location in java application
String path = "C:" + File.separator + "hello" + File.separator + "hi.txt";
// Use relative path for Unix systems
File f = new File(path);
f.getParentFile().mkdirs();
f.createNewFile();