Solved programming problem

Read Roll,id & name from a file and Write some

Source code

package roll_id;

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.PrintWriter;

import java.util.logging.Level;

import java.util.logging.Logger;

public class FileIO

{

    public void readInput() {

        BufferedReader br = null;

        String line;

        try {

            br = new BufferedReader(new FileReader("input.txt"));

            PrintWriter write = new PrintWriter("output.txt");

            while((line = br.readLine())!=null)

            {

               

              String a[] =line.split(" ");

              System.out.println("Name: "+a[1]);

              System.out.println();

         

            write.println("Id: "+a[0]+ " CGPA: "+a[2]);

         

            }

           write.close();

        } catch (Exception ex) {

            ex.printStackTrace();

        }

    }

 

}

Output

Input File:

 

 

 

 

 

 

 

 

 

 

 

Output File:

Join the discussion

Add your comment

1 previous comment

acb

sir, please provide a java project for lab.