Reading bytes from File

import java.io.*;
public class RdFile {
    public static void main(String args[]) throws IOException
    {
        if(args.length != 1)
        {
            System.out.println("\nFile Not Found.....!!!");
            System.exit(0);
        }
        File f=new File(args[0]);
        byte b[]={};
        //Reading File...
        if(f.exists())
        {
            FileInputStream f1=new FileInputStream(f);
            int num=f1.available();
            b=new byte[num];
            int n=f1.read(b);
            String str=new String(b);
            System.out.println("\nContent :"+str);
            f1.close();
            f=null;
        }
        else
        {
            System.out.print("\nFile Does not Exist");
            System.exit(0);
        }
      
}
}


No comments: