java create file if not exists
String yourFile = "YourFile.txt";
String yourContent = "YourContent"
File tmpDir = new File(yourFile);
boolean exists = tmpDir.exists();
if(!exists) {
FileOutputStream fos = new FileOutputStream(yourFile);
fos.write(yourContent.getBytes());
fos.flush();
fos.close();
}
Also in Java:
- while loops java
- how to take space separated input in java
- generic method lambda java
- java for loop add multiple declarations
- java search file in folder
- multiplication program java
- spigot custom mob
- how to print hello world in java
- how to create a Rectangle in java
- how to cut a certion part from a string in java
- java.lang.UnsupportedOperationException
- java random between two strings
- java check if args is empty
- how to initialize an array in java
- how to convert char to uppercase java
- java resultset to table
- java create file if not exists
- creating random color in java
- jbutton open jframe java
- Java 2 dimensional array equals
- processing sound android
- java output array lists to file
- how to pass parameters to xsl file
- java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.security.MessageDigest$Delegate