Created
March 28, 2022 15:26
-
-
Save SmashedFrenzy16/fc0a7ba94886ea42fe05e651d00124f1 to your computer and use it in GitHub Desktop.
A Java File Creator.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
public class fileCreator { | |
public static void main(String[] args) { | |
try { | |
File myObj = new File("textdoc1.txt"); | |
if (myObj.createNewFile()) { | |
System.out.println("The following file was created: " + myObj.getName()); | |
} else { | |
System.out.println("This file already exists on this device."); | |
} | |
} catch (IOException e) { | |
System.out.println("An error occured."); | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment