The following code 'll create a file 'examplefile.txt',if doesn't exist
try {
File file = new File("examplefile.txt");
// Create file if it does not exist
boolean success = file.createNewFile();
if (success) {
// File did not exist and was created
} else {
// File already exists
}
} catch (IOException e) {
e.printStackTrace();
}
try {
File file = new File("examplefile.txt");
// Create file if it does not exist
boolean success = file.createNewFile();
if (success) {
// File did not exist and was created
} else {
// File already exists
}
} catch (IOException e) {
e.printStackTrace();
}
No comments:
Post a Comment