Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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();
}
 
PREVIOUS NEXT
Tagged: #java #create #file #exists
ADD COMMENT
Topic
Name
2+7 =