
how to read and write the data from text file.Suppose i have text file with 4 fields name ,roll no ,marks1,marks2 with more than 20 records......i need to store these value in object and pass to the other class.Suggestion please

hi Dhirendra, here I am giving a sample code
code for writing object
oos = new ObjectOutputStream(fos);
oos.writeObject("Ankit");
oos.writeObject("Content Writer");
oos.writeInt(8000);
oos.writeObject("Ankit");
oos.writeObject("Java Developer");
oos.writeInt(20000);
System.out.println();
System.out.println("objects written to the stream successfully");
2. code for reading object
ois = new ObjectInputStream(fis);
String sh = (String) ois.readObject();
String cw = (String) ois.readObject();
int sal = ois.readInt();
String am = (String) ois.readObject();
String cw1 = (String) ois.readObject();
int sal1 = ois.readInt();
System.out.println();
System.out.println("Name \t"+"Department \t"+"Salary");
System.out.println(sh+"\t"+cw+"\t"+sal);
System.out.println(am+"\t"+cw1+"\t"+sal1);
for complete tutorial you can follow this link
Java ObjectOutputStream ObjectInputStream
http://roseindia.net/java/example/java/io/objectinputoutputstream.shtml
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.