Something like:
File file = new File("C:\\user\\Desktop\\dir1\\dir2\\filename.txt");
file.getParentFile().mkdirs();
FileWriter writer = new FileWriter(file);
More Related Contents:
- Get location of JAR file
- Java FileReader and FileWriter copy a textfile on another
- How to get the path of a running JAR file?
- Android – Get real path of a .txt file selected from the file explorer
- How to read all files in a folder from Java?
- How to get a path to a resource in a Java JAR file
- How to construct a relative path in Java from two absolute paths (or URLs)?
- Copying files from one directory to another in Java
- Java FileWriter with append mode
- Getting the filenames of all files in a folder [duplicate]
- How to update PATH variable permanently from Windows command line?
- Create a new line in Java’s FileWriter
- How to create a folder in Java?
- how to zip a folder itself using java
- Trouble with filewriter overwriting files instead of appending to the end
- How to locate the Path of the current project directory in Java (IDE)?
- PrintWriter vs FileWriter in Java
- Maven – how to include empty directories
- Setting up enviromental variables in Windows 10 to use java and javac
- Using bash, how do you make a classpath out of all files in a directory?
- flush in java.io.FileWriter
- How to get current working directory in Java?
- Ant path style patterns
- Find files in a folder using Java
- list all files from directories and subdirectories in Java
- Getting directory path to .class file containing main
- Difference between Package and Directory in Java
- Setting up enviroment variables in Windows 10 to use java and javac
- Setting the correct PATH for Eclipse
- How can I set the PATH variable for javac so I can manually compile my .java works?