You are on page 1of 1

package com.

javaexercise1;

import java.io.*;
import java.util.Scanner;

public class Main {

public static void main(String[] args) {


// write your code here
/* try {
File myfile = new File("S:\\Object Oriented and Event Driven
Programming\\FIO\\filee.txt");
if (myfile.createNewFile()) {
System.out.println("File Create " + myfile.getName());
} else {
System.out.println("File Was Not Created");
}
} catch (IOException e) {
System.out.println("Error Occured File Was Not Created");
e.getStackTrace();
}*/
/*try{
FileWriter wr=new FileWriter("S:\\Object Oriented and Event Driven
Programming\\FIO\\flee.txt");
wr.write("This Script is Written with the file\n");
wr.write("And this two is written within the file\n");
wr.write(89903093);
wr.close();
System.out.println("Something is written in the file");
} catch (IOException e){
System.out.println("Nothing Written");
e.getStackTrace();
}*/
/* try{
FileReader re=new FileReader("S:\\Object Oriented and Event Driven
Programming\\FIO\\flee.txt");
Scanner read=new Scanner(re);
while (read.hasNextLine()){
String dt=read.nextLine();
System.out.println(dt);
}
read.close();
}catch (Exception e){
System.out.println("File not Read");
e.printStackTrace();
}*/
File fl=new File("S:\\Object Oriented and Event Driven
Programming\\FIO\\filee.pdf");
if(fl.delete()){
System.out.println("The file name: "+fl.getName()+" Is Deleted");
}else{
System.out.println("File Failed to be deleted");
}
}
}

You might also like