Created
May 15, 2010 11:11
-
-
Save rewbs/402141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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