add files

This commit is contained in:
2026-05-10 16:35:22 +03:30
parent f29dc564fb
commit 42f07c638d
14 changed files with 420 additions and 0 deletions
@@ -0,0 +1,43 @@
package org.FileExamples.CreatingFiles;
import java.io.File;
import java.io.IOException;
public class CreateFileExample01 {
static void main() {
File file = new File("quotes.txt");
try {
if(file.createNewFile())
{
System.out.println("created new file");
}
else
{
System.out.println("file already exists");
}
} catch (IOException e) {
System.err.println(e.getMessage());
}
File newfile = new File("newfolder/quotes.txt");
try {
newfile.getParentFile().mkdirs();
if(newfile.createNewFile())
{
System.out.println("created new file");
}
else
{
System.out.println("file already exists");
}
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
//TODO: 1. Create File
//TODO: 2. Specify and address and directory that exists
//TODO: 3. Specify and address and directory that does not exists
//TODO: 4.
}