Need help parsing and large file reading-urgent please

import java.io.*;
import java.lang.String.*;
import java.util.*;
public class ReadFile {
//--------------------------------------------------< main >--------//
public static void main (String[] args) {
ReadFile t = new ReadFile();
t.readMyFile();
//--------------------------------------------< readMyFile >--------//
void readMyFile() {
String line = null;
String dcn = null;
String pfn = null;
String pln = null;
String pdob = null;
String ssd = null;
try {
FileReader fr = new FileReader("C:\\ClaimsData\\ClaimsExtract.txt");
BufferedReader br = new BufferedReader(fr);
line = new String();
while ((line = br.readLine()) != null) {
//A00002314376A5272201102300000000MASARU OKUDA 1933012520050722B101 20051001
//Each line of ClaimsExtract.txt is exactly in above form
// and there are about 1000 such lines
dcn = new String();
pfn = new String();
pln = new String();
pdob = new String();
ssd = new String();
dcn = line.substring(13,24);
pfn = line.substring(32,42);
pln = line.substring(42,57);
pdob = line.substring(57,65);
ssd = line.substring(65,73);
//System.out.println(dcn+" "+pfn+" "+pln+" "+pdob+" "+ssd);
fr.close();
} catch (IOException e) {
// catch possible io errors from readLine()
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
} // end of readMyFile()
} // end of class
java.io.IOException: Stream closed
     at sun.nio.cs.StreamDecoder.ensureOpen(StreamDecoder.java:37)
     at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:152)
     at java.io.InputStreamReader.read(InputStreamReader.java:167)
     at java.io.BufferedReader.fill(BufferedReader.java:136)
     at java.io.BufferedReader.readLine(BufferedReader.java:299)
     at java.io.BufferedReader.readLine(BufferedReader.java:362)
     at ReadFile.readMyFile(ReadFile.java:32)
     at ReadFile.main(ReadFile.java:14)
Uh oh, got an IOException error!
I also tried using Tokenizer but some other errors, Please suggest a better approach
urgent , Thanks in Advance

i think your while loop has the problem. It's keep continuing to read the next line in the file and doesn't exit even when it reaches the end of file. Therefore it gives you that error. Since you're using variable line as string object hence for the while loop you should've something like this and i would also move the reading next line part just before ending the while loopwhile ( ! line.equals(null) ) {
       line = br.readLine();
}//end of while because string object doesn't work for comparing operators == or != so you always have to use string.equlas()
I'm sure that's the reason you're encountering this error, otherwise please specify the line where you're encountring the problem. Next time please use the tags for your code becuase it formats the code nicely and it's easy to read it. Cheers
Message was edited by:
        salubadsha                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    You mean an image such as a scanned document?
    If that is the case, the file doesn't contain any text for Reader Out Loud to read. In order to fix that, you would need an application such as Adobe Acrobat that does Optical Character Recognition to convert the images to actual text.
    You can also try to export the file as a Word document or something else using ExportPDF which I believe offers OCR and is cheaper than Acrobat.

  • I need help because I can't read my redemption code on my iTunes giftcard and I can't wait 48 hours for a response via e-mail.

    I need help because I can't read my redemption code on my iTunes gitfcard and I can't wait 48 hours for a response via e-mail.

    How can i help you?

  • This Adobe muse site file requires a newer version of Adobe Muse. I want to comeback to old version Adobe muse i need help to open my file thanks

    This Adobe muse site file requires a newer version of Adobe Muse. I want to comeback to old version Adobe muse i need help to open my file thanks

    Hi,
    You may need to design the site again in older version OR may be copy and paste in place from new to old except what is new in the latest version.
    Hope that helps!
    Kind Regards,

  • Need help in laoding flat file data, which has \r at the end of a string

    Hi There,
    Need help in loading flat file data, which has \r at the end of a string.
    I have a flat file with three columns. In the data, at the end of second column it has \r. So because of this the control is going to the beginning of next line. And the rest of the line is loading into the next line.
    Can someone pls help me to remove escape character \r from the data?
    thanks,
    rag

    Have you looked into the sed linux command? here are some details:
    When working with txt files or with the shell in general it is sometimes necessary to replace certain chars in existing files. In that cases sed can come in handy:
    1     sed -i 's/foo/bar/g' FILENAME
    The -i option makes sure that the changes are saved in the new file – in case you are not sure that sed will work as you expect it you should use it without the option but provide an output filename. The s is for search, the foo is the pattern you are searching the file for, bar is the replacement string and the g flag makes sure that all hits on each line are replaced, not just the first one.
    If you have to replace special characters like a dot or a comma, they have to be entered with a backslash to make clear that you mean the chars, not some control command:
    1     sed -i 's/./,/g' *txt
    Sed should be available on every standard installation of any distribution. At lesat on Fedora it is even required by core system parts like udev.
    If this helps, mark as correct or helpful.

  • I need help deleting and adding text

    i need help deleting and adding text, can soneone help
    Adobe Photoshop Elements 10

    You should delete your phone number from the topic line.
    Spambots search these forums for contact info.
    You don't want to get even more telemarketing/scam calls than you probably already get.
    It seems like the "Do Not Call" lists are ignored these days.
    Message was edited by: Bo LeBeau       Looks like someone already took care of this.

  • TS4185 I have downloaded facetime from the App store and I keep receiving this message - An internal FaceTime error occurred.  There was a problem with FaceTime. You need to quit and open FaceTime again.  Please help!

    I have downloaded facetime from the App store and I keep receiving this message - An internal FaceTime error occurred.  There was a problem with FaceTime. You need to quit and open FaceTime again.  Please help!

    This error message could result from an incorrect setting for date and time, or an operating system which does not have the latest updates installed.  It's a good idea to have your location setting on automatic.  Turn on the wi fi in your mac for a minute or so, to allow it to automatically search for your present location.  Do this even though you have the correct time Date settings displayed.

  • I bought 2 same plan for Lightroom accidentally and need to terminate and cancel both of them,please help me

    I bought 2 same plan for Lightroom accidentally and need to terminate and cancel both of them,please help me

    Unfortunately, you will have to contact Adobe directly to do this sort of thing, with the best bet being by phone. They may, or may not, be willing to refund you your purchase cost.

  • I need help scrolling and highlighting for a vast amount of pics that I'm trying to transfer. I have a macbook pro osx 10.5.8

    I need help scrolling and highlighting for a vast amount of pics that I'm trying to transfer. I have a macbook pro osx 10.5.8

    I need help scrolling and highlighting for a vast amount of pics that I'm trying to transfer. I have a macbook pro osx 10.5.8

  • I actually need help but cannot find the answer. Please.......Lately when open a new tab it does not open with a blank page. I don't want to set my homepage as

    I actually need help but cannot find the answer.
    Please.......Lately when open a new tab it does not open with a blank page. I don't want to set my homepage as blank as when I first open Firefox, it automatically loads my hotmail page. But then if I open other pages I don't get a blank page. Help, please?
    Thank you.
    ''[Personal information removed by moderator. Please read [[Forum and chat rules and guidelines]], thanks.]''

    hello, please refer to [[New Tab Page – show, hide and customize top sites]] in order to switch the feature off.

  • MOVED: need help with my k7n2 delta series motherboard please

    This topic has been moved to AMD SocketA based board.
    need help with my k7n2 delta series motherboard please

    "...the other memory ive been using is  memorymaxx 512mb ddr 3200..." If I understood right, your'e actually using both memories at same time so, your'e lucky if it works. We have said thousand times that mixing dif. brand/make/speed memories is a bad idea, most with this Mobo that is very picky about ram. If you want to avoid slowdown problems, stay with only one stick ( the better one ) until you can buy at same time in same store, 2 identical memories to replace the old one.

  • I have an iphone 4 and it will not boot. I've done everything except downgrade the firmware to 6.1.3 or 6.1.4... is this what needs to happen and if so can I please get a link to do so? thanks

    I have an iphone 4 and it will not boot. I've done everything except downgrade the firmware to 6.1.3 or 6.1.4... is this what needs to happen and if so can I please get a link to do so? thanks

    Hi JACOBfromINSIDEaLION,
    If you are unable to get your iPhone to restore, you will want to perform a restore from recovery mode, as explained in the following article:
    If you can't update or restore your iOS device
    http://support.apple.com/kb/HT1808
    Thanks for being a part of the Apple Support Communities!
    Cheers,
    Braden

  • HT4199 I need help with getting my printer to print, PLEASE.

    I need help with getting my printer to print, Please.

    What have you done so far?
    I suggest you connect it via a usb  cable first.  Once you get the printer working, move to wifi.  You will have to use an existing printer usb cable or purchase a cable.  Be sure to get the correct cable.  Ask for help.
    The warrenty indicates there is phone support.  Give HP a call.
    Warranty
    One-year limited hardware warranty; 24-hour, 7 days a week phone support
    Robert

  • I need help with a backup file that was deleted and now undeleted from my hard drive

    Last month (May 6, 2011), I was updating my iPod Touch 4G with the new software that came out. I always make a backup of my iPod's data before I update it. While my iPod was updating I left my iPod and computer alone and was doing things around the house with my mom. And when I was done I went in my room to see if it was done and my computer decides that it was going to freeze and crash on me (with my iPod plugged in and stuck on the updating or verifying software mode.) I managed to get my iPod back to working condition again but losing everything on my iPod. I formatted my computer hard drive but I managed to get back the backup I lost. I need help on getting the backup into iTunes so I can get my data back. I am not Jailbroken and I plan not to Jailbreak. I however saved the backup file in a folder other than the Mobilesync folder. I am also running on Windows XP. Someone please help me and thank you in advance!

    I was able to backup my iPod and I tried to restore my iPod again and it goes through the process and everything but it restores the temporary data that I had on there. It didn't restore application data or the current photos and videos that I had saved in Camera Roll before this all had happened. It is almost like it goes back to factory settings but I have some photos that were saved on the other backup that I was temporarily running on. The backup that I am looking to restore is the only backup file in the Mobilesync folder as of right now the others are saved somewhere safe for right now. Why doesn't it restore my application data or my Camera Roll pictures and videos that I saved before my computer crashed last month? Can this problem be fixed?

  • Large File Reading and Processing

    Hi:
    Suppose I have a file much larger than my computer's memory e.g. say on a Windows XP system, the memory is 256 MB RAM and the file size is 1 GB on disk. Now if I want to create a File object and read from this file, is this possible to do? If yes, how about the performance?
    I understand that this is more of an Operating System question but nevertheless it affects the Java process.
    Thanks!
    Rahul.

    If you mean, you plan to read the whole file into memory, then:
    Theoretically possible, sure. The process would be much bigger (in terms of memory used) than the amount of memory available, which means that it would start swapping out to disk, and that would reduce performance, although to what extent depends on XP's virtual memory implementation, which I know nothing about.
    But if all you mean is that you want to create a File object and read bits of the file, it won't make any difference. File represents a name or description of a file, not the file itself (you can create File objects for files that don't exist). So it doesn't need to read the whole into memory just to create a File object. You can easily create a File object for the huge file, and then read it in line by line, throwing away old lines as you go, and you won't use up very much memory at all. (Unless, of course, there's some horrible weird artifact of XP that I'm not aware of.)

Maybe you are looking for