import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Shahzads */ public class assignment { public static void main(String[] args) throws IOException{ String[] key_Words=new String[11]; key_Words[0]="int"; key_Words[1]="long"; key_Words[2]="public"; key_Words[3]="static"; key_Words[4]="void"; key_Words[5]="main"; key_Words[6]="print"; key_Words[7]="println"; key_Words[8]="System"; key_Words[9]="out"; key_Words[10]="class"; BufferedReader b_R=new BufferedReader(new InputStreamReader(System.in)); String file_Name=null; // file_Name = b_R.readLine(); file_Name="D:\\a.txt"; File file=new File(file_Name); FileInputStream f_IS=new FileInputStream(file); BufferedInputStream b_IS=new BufferedInputStream(f_IS); DataInputStream d_IS=new DataInputStream(b_IS); while(d_IS.available()!=0){ String line=b_R.readLine(); System.out.println(line); } d_IS.close(); b_IS.close(); f_IS.close(); /*while(line!=null){ System.out.println(line); line=b_R.readLine(); }*/ } }
I want to read the file but i don't know why it's not reading the first line. Can any of you suggest me, where to look exactly.... Thanks for reading the post.