java create file in folder
File file = new File("src/resources/run.txt");
file.getParentFile().mkdirs();
FileWriter writer = new FileWriter(file);
writer.append("this is a test");
writer.close();
java create file in folder
File file = new File("src/resources/run.txt");
file.getParentFile().mkdirs();
FileWriter writer = new FileWriter(file);
writer.append("this is a test");
writer.close();
How to create directory in java
// mkdirs() method in java example
import java.io.File;
public class CreateDirectoryDemo
{
public static void main(String[] args)
{
File directory = new File("D:\\DirectoryExample\\subdirectory1\\subdirectory2");
if(!directory.exists())
{
if(directory.mkdirs())
{
System.out.println("Sub directories created");
}
else
{
System.out.println("Sub directories not created");
}
}
}
}
java create file in folder
File file = new File("src/resources/run.txt");
file.getParentFile().mkdirs();
file.createNewFile();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us