26 lines
561 B
Java
26 lines
561 B
Java
package org.FileExamples.CreatingFiles;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
public class CreateFileExample01 {
|
|
static void main() {
|
|
File file = new File("texts/examples.txt");
|
|
try
|
|
{
|
|
if(file.createNewFile())
|
|
{
|
|
System.out.println("File created");
|
|
}
|
|
else
|
|
{
|
|
System.out.println("File already exists");
|
|
}
|
|
}
|
|
catch(IOException e)
|
|
{
|
|
System.err.println(e.getMessage());
|
|
}
|
|
}
|
|
}
|