Download 2.3 1221

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Worksheet – 2.3
Name : Manish Baldia
Branch : CSE
UID : 20BCS1221
Subject : Java lab
Aim of the practical:
Program to read and write data to a file.
Code:
import java.io.*;
class Main
{
public static void main(String[] args) throws Exception
{
FileWriter fw = new FileWriter("D:\\javatest.txt");
FileReader fr = new FileReader("D:\\javatest.txt");
fw.write("Hello World!!!");
int i;
while((i=fr.read())!=-1)
{
System.out.println((char) i);
}
fr.close();
fw.close();
System.out.println("Success!!!");
}
}
Output: