try { FileInputStream stream = new FileInputStream(myFile); DataInputStream input = new DataInputStream(stream); while (input.available() != 0) { System.out.println (input.readLine()); } input.close(); } catch (Exception e) { System.err.println("Could not read from file"); } #### open INPUT, "<", $input or die "Cannot open ($input) for reading: $!"; print ; close INPUT or die "Could not close $input: $!";