demo java file
// importing the File class
import java.io.File;
class Main {
public static void main(String[] args) {
// create a file object for the current location
File file = new File("newFile.txt");
try {
// trying to create a file based on the object
boolean value = file.createNewFile();
if (value) {
System.out.println("The new file is created.");
}
else {
System.out.println("The file already exists.");
}
}
catch(Exception e) {
e.getStackTrace();
}
}
}
Also in Java:
- Don't use a line-beased input after a token-based input.
- butterfly pattern program in java
- deleting elements of an array in java
- get current unix timestamp java
- java jaxb unmarshall xml to map
- dataframe to dict without index
- how to create a thread local variable in java
- get first 5 characters of string java
- bukkit java get max players
- HOW TO SUPRESS sonar warning in java code
- how to print in java
- java final meaning
- java int to string
- java create folder
- formatting an integer in java
- how to ask user for his location in android
- converter int array para string java
- java int array
- java initialize string array
- java append to array
- Matlab java.lang.IllegalArgumentException: Invalid range
- how to create a circle in java
- indexof java
- spring iterate