import java.io.FileInputStream;
import java.io.FileOutputStream;
public class Student {
public static void main(String[] args) {
System.out.println("-------Writing Data in File-------");
try {
FileOutputStream fout = new FileOutputStream("stdinfo.txt");
String str = "Nmae : Sachin, Stream : Computer Engineering, Sem : 5th Sem";
byte b[] = str.getBytes();
fout.write(b);
fout.close();
System.out.println("successful write.");
} catch (Exception e) {
System.out.println(e);
}
System.out.println("-------Retrive Data From File-------");
try {
FileInputStream fin = new FileInputStream("stdinfo.txt");
int i = 0;
while ((i = fin.read()) != -1) {
System.out.print((char) i);
}
fin.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
Find all the practical at one place of Gujarat Technological University(GTU) With Solutions.
Sunday, June 30, 2019
Create a class called Student. Write a student manager program to manipulate the student information from files by using FileInputStream and FileOutputStream
Subscribe to:
Post Comments (Atom)
-
A country has a capital city A dining philosopher uses a fork A file is an ordinary file or a directory file Files cont...
-
import java.io.*; public class Dataio { public static void main(String args[]) throws IOException { DataInputStr...
No comments:
Post a Comment