package colections;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FilereaderDemo {
public static void main(String[] args) throws IOException {
FileWriter fw = new FileWriter("R:\\Bore\\Eclipse Workspace\\Testing\\src\\colections\\test1.txt");
String s = "Hello Raviteja welcome to India";
fw.write(s);
fw.close();
FileReader fr = new FileReader("R:\\Bore\\Eclipse Workspace\\Testing\\src\\colections\\test1.txt");
char []c = new char[500];
fr.read(c);
System.out.println(c);
//converting char to String
String s3 = String.valueOf(c);
System.out.println(s3);
//without converting char to string ,Using for loop
for(char s1 :c)
System.out.print(s1);
fr.close();
}
}
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FilereaderDemo {
public static void main(String[] args) throws IOException {
FileWriter fw = new FileWriter("R:\\Bore\\Eclipse Workspace\\Testing\\src\\colections\\test1.txt");
String s = "Hello Raviteja welcome to India";
fw.write(s);
fw.close();
FileReader fr = new FileReader("R:\\Bore\\Eclipse Workspace\\Testing\\src\\colections\\test1.txt");
char []c = new char[500];
fr.read(c);
System.out.println(c);
//converting char to String
String s3 = String.valueOf(c);
System.out.println(s3);
//without converting char to string ,Using for loop
for(char s1 :c)
System.out.print(s1);
fr.close();
}
}
No comments:
Post a Comment