Skip to content

Instantly share code, notes, and snippets.

@rewbs
Created May 15, 2010 11:11
Show Gist options
  • Save rewbs/402141 to your computer and use it in GitHub Desktop.
Save rewbs/402141 to your computer and use it in GitHub Desktop.
import java.io.*;
public class Play {
public static void main(String args[]) throws IOException {
// my_IBM1388_file is a text file encoded in IBM-1388 with the following 3 lines of content:
// Line 1/3 of an IBM-1388 file.
// Line 2/3 of an IBM-1388 file.
// Line 3/3 of an IBM-1388 file.
FileInputStream fis = new FileInputStream("my_IBM1388_file");
BufferedReader br = new BufferedReader(new InputStreamReader(fis, "IBM-1388"));
// Print each line in the file. Break if we see 10 lines to avoid infinite loop.
String s;
int counter = 0;
while ((s = br.readLine()) != null) {
System.out.println(s);
if (++counter > 10) {
System.out.println("Looks like we're in a loop - breaking.");
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment