File Handling:
1)it is a pre-defined class and it is in an io package
2)it is process,to perform an opreation on file by set of codes
3)it consist of a CreateNewFile()-to create an empty file in a package or a particular location
{
File file=new File("C:\Users\tpavi\OneDrive\Music\sample2");
try {
file.createNewFile();
}
catch(Exception e)
{
System.out.println(" invalid");
}
}
}
FileWriter:
1)it is a pre-defined class and it is in io package
2)it is to write the statement inside the file by write()
{
try {
FileWriter file=new FileWriter("C:\Users\tpavi\OneDrive\Music\sample2");
file.write("welcome java ");
file.close();
}
catch(Exception e)
{
System.out.println("");
}
}
}
FileReader():
1)it is a pre-defined class and it is in io package
2)it is to fetch the statement,which is inside the file by read()
{
file_reade fil=new file_reade();
fil.method1();
}
void method1() {
try {
FileReader fr=new FileReader("C:\\Users\\tpavi\\OneDrive\\Music\\sample2");
int c = 0;
while(c!=-1)
{
System.out.print((char)c);
c = fr.read();
}
fr.close();
}
catch(Exception e)
{
System.out.println("inavaild");
}
}
}
Top comments (0)