attach if file item is not attached laravel code example

Example 1: python create file if not exists

import os

if not os.path.exists(path):
    with open(path, 'w'):

Example 2: 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();
}

Tags:

Java Example