1st is to obtain data from this text file n simply show in the console n then to show the information separated by commas under the columns of name: roll number: class: phone number: course:
secondly it's to tell that how much characters, integers, blank spaces are in the .txt file...
FILE DATA:
andre neil, 211, IT, 04130001701, BSCS
David miller, 219, CS, 0234000201, BSCS
Johnson, 344, Maths, 0523400000478, BS(Maths)
import java.util.*; import javax.swing.*; import java.io.*; public class TestStudent{ public static void main(String args[]){ FileReader fr = null; BufferedReader br = null; String[] tokens=null; try{ fr = new FileReader("student.txt"); br = new BufferedReader(fr); String line = br.readLine(); while (line !=null) { tokens= line.split(","); System.out.println(line); line = br.readLine(); } br.close(); fr.close(); } catch(IOException ioex){ System.out.println(ioex); } System.out.println("student no.1"); Student s1 =new Student(tokens[0],tokens[1], tokens[2], tokens[3], tokens[4]); s1.print(); }
it's giving me just the last student's data
student class is another file just to show the columns headings accordingly...