Something like:
File file = new File("C:\\user\\Desktop\\dir1\\dir2\\filename.txt");
file.getParentFile().mkdirs();
FileWriter writer = new FileWriter(file);
Related Contents:
- Check if a path represents a file or a folder
- How to read all files in a folder from Java?
- How to get the path of a running JAR file?
- How to create a directory in Java?
- Getting the filenames of all files in a folder [duplicate]
- How to combine paths in Java?
- How to create a temporary directory/folder in Java?
- How to construct a relative path in Java from two absolute paths (or URLs)?
- javac is not recognized as an internal or external command, operable program or batch file [closed]
- Get java.nio.file.Path object from java.io.File
- Java: Path vs File
- How to get a path to a resource in a Java JAR file
- Copying files from one directory to another in Java
- How can I access a folder inside of a resource folder from inside my jar File?
- Does Java have a path joining method? [duplicate]
- Ant path style patterns
- Difference between mkdir() and mkdirs() in java for java.io.File [closed]
- How to update PATH variable permanently from Windows command line?
- How to iterate over the files of a certain directory, in Java? [duplicate]
- How to get current working directory in Java?
- How to add native library to “java.library.path” with Eclipse launch (instead of overriding it)
- Java’s createNewFile() – will it also create directories?
- How to check the extension of a Java 7 Path
- deleting folder from java [duplicate]
- JAVA_HOME directory in Linux
- Java Package Vs Folder-Structure? what is the difference
- how to zip a folder itself using java
- How to locate the Path of the current project directory in Java (IDE)?
- Counting the number of files in a directory using Java
- How to access a sub-file/folder in Java 7 java.nio.file.Path?
- When to use ** (double star) in glob syntax within JAVA
- Using bash, how do you make a classpath out of all files in a directory?
- How to scan a folder in Java?
- InputStream from relative path
- Convert URL to normal windows filename Java
- Java.nio: most concise recursive directory delete
- Find files in a folder using Java
- java hsperfdata directory [closed]
- How to create a folder in Java?
- Setting up enviroment variables in Windows 10 to use java and javac
- Create a new line in Java’s FileWriter
- Netbeans – is it possible to see project source folders in a tree (hierarchical) view, rather then a flat view?
- Selecting Folder Destination in Java?
- When to use: Java 8+ interface default method, vs. abstract method
- How to convert Milliseconds to “X mins, x seconds” in Java?
- Why is Java’s SimpleDateFormat not thread-safe? [duplicate]
- How to handle invalid SSL certificates with Apache HttpClient? [duplicate]
- Is it legal to call the start method twice on the same Thread?
- “The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe”
- Circular References in Java