Results 1 to 4 of 4
Thread: Scanning a Plain text file
- 02-03-2012, 03:34 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 4
- Rep Power
- 0
Scanning a Plain text file
Hey all,
Ive encountered a dilema and unsure as to what the problem is, i have this piece of code that scans a text file and prints it....the problem is that it prints to the 269th line and then stops. This is the problem because the file has more than 1.4million lines.
This is the current code that i have:
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class ScannerApp2 {
public static void main(String[] args)
{
try
{
File file = new File("E:\\CO600\\misc\\movies.txt");
Scanner scanner = new Scanner(file);
while (scanner.hasNext())
{
System.out.println(scanner.nextLine());
}
scanner.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
}
Please help because this is actually doing my head in.
Many thanks
- 02-03-2012, 03:37 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,604
- Blog Entries
- 7
- Rep Power
- 17
Re: Scanning a Plain text file
Can you show us the content of that file around line #269? I suspect an en/decoding problem.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-03-2012, 03:47 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 4
- Rep Power
- 0
Re: Scanning a Plain text file
Hey thanks for the quick reply, this is the output:
264 : "'Allo 'Allo!" (1982) {Flight of Fancy (#3.4)} 1986
265 : "'Allo 'Allo!" (1982) {Forged Francs & Fishsellers (#5.15)} 1988
266 : "'Allo 'Allo!" (1982) {Free at Last! (#7.2)} ????
267 : "'Allo 'Allo!" (1982) {Good Staff Are Hard to Find (#4.3)} 1987
268 : "'Allo 'Allo!" (1982) {Gruber Does Some Mincing (#3.2)} 1986
269 : "'Allo 'Allo!" (1982)
BUILD SUCCESSFUL (total time: 1 second)
And this is how it is displayed in the the file itself, mind you the file is 91mb:
"'Allo 'Allo!" (1982) {Good Staff Are Hard to Find (#4.3)} 1987
"'Allo 'Allo!" (1982) {Gruber Does Some Mincing (#3.2)} 1986
"'Allo 'Allo!" (1982) {Hans Goes Over the Top (#4.1)} 1987
"'Allo 'Allo!" (1982) {Herr Flick's Revenge (#2.6)} 1985
- 02-03-2012, 05:16 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,604
- Blog Entries
- 7
- Rep Power
- 17
Re: Scanning a Plain text file
Can you (hex) dump around that line? Make sure there are no funny bytes on that line because the scanner has no reason to give up unless it reads a byte with a funny value,say, 0x1a or similar.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
plain text printing with java
By berkeleybross in forum Advanced JavaReplies: 3Last Post: 04-04-2011, 01:01 AM -
Combobox from plain text file (plain text file database)
By cotarelo in forum AWT / SwingReplies: 3Last Post: 06-08-2010, 08:10 PM -
Scanning text file and inserting contents into array
By jmwalloh in forum New To JavaReplies: 8Last Post: 03-24-2010, 12:33 PM -
Indentation - plain text
By barney75 in forum New To JavaReplies: 1Last Post: 03-23-2009, 05:54 PM -
convert html to plain text
By vissu007 in forum New To JavaReplies: 3Last Post: 07-07-2007, 02:39 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks