please give me a solution

Posted by user327832 on Stack Overflow See other posts from Stack Overflow or by user327832
Published on 2010-04-28T12:48:21Z Indexed on 2010/04/28 12:53 UTC
Read the original article Hit count: 232

Filed under:
|

here is the code i have written so far but ended up giving me error

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {
  public static void main(String[] args) throws Exception {
    File file = new File("c:\\filea.txt");
    InputStream is = new FileInputStream(file);

    long length = file.length();
    System.out.println (length);    
    bytes[] bytes = new bytes[(int) length];

    try {
      int offset = 0;
      int numRead = 0;
      while (numRead >= 0) {
        numRead = is.read(bytes);
      }
    }
    catch (IOException e) {
     System.out.println ("Could not completely read file " + file.getName());
    }

    is.close();
    Object[] see = new Object[(int) length];
    see[1] = bytes;
    System.out.println ((String[])see[1]); 
  }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about file-io