Answers for "read file java if does not exists create"

1

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

Code answers related to "read file java if does not exists create"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language