/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author ICI Makati */ import java.io.*; public class FileRead { /** * @param args the command line arguments */ public static void main(String[] args){ try{ //Open the file that is the first //command line parameter FileInputStream fstream= new FileInputStream("textfile.txt"); //Get the object of DataInputStream DataInputStream in= new DataInputStream(fstream); BufferedReader br= new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line by Line while ((strLine = br.readLine())!=null){ //print the content on the console System.out.println(strLine); } //Close teh input stream in.close(); }catch(Exception e){System.err.println("Error: "+e.getMessage()); } }