Answers for "java create folder at program files"

2

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();
Posted by: Guest on October-26-2020
1

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");
         }
      }
   }
}
Posted by: Guest on December-01-2020
1

java create file in folder

File file = new File("src/resources/run.txt");

file.getParentFile().mkdirs();

file.createNewFile();
Posted by: Guest on October-26-2020

Code answers related to "java create folder at program files"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language