wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Not able to write the whole content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Not able to write the whole content" Watch "Not able to write the whole content" New topic
Author

Not able to write the whole content

Shanmugam Muthukumarasamy
Ranch Hand

Joined: Jan 11, 2003
Posts: 83
Hi All,
I am trying to read one text file and I am removing some unwanted words and characters from that and then trying to write into a new file. It is not writing all the content of the source to the destination. I am using a simple program with BufferedReader. I am not giving any buffer size for BufferedReader, will it restrict to stop write the content of the source.
Here I have pasted my code, Please let me know what could be the reason.
I am getting only part of the content from the source file. But I want the full information.
I tried to print the content before writing into source file, it is printing the whole content from the source file, but while creating the file it is not putting the missed information.
Thanks in advance,
Shanmugam.
========================

[ August 21, 2003: Message edited by: jason adam ]

SJCP 1.4<br />SCWCD 1.4<br />SCEA
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
First, I would put in a finish block that flushes your writer and then closes the reader/writer. Just good practice.
As for what information is being put into the file, your loop is only sticking the lines from one file into the other if they don't start with * or '. So you aren't going to get ALL of the data from one file into the other, unless none of the lines meet the above conditions.
Without showing any data, can you give an example of what sort of pattern, if any, that you are seeing in regards to what data is being put into the temp file and which data isn't? Maybe we can determine why certain lines are being dropped.
Shanmugam Muthukumarasamy
Ranch Hand

Joined: Jan 11, 2003
Posts: 83
The content of the source text file looks like this way:
*-----------------------------------------------------------------CADKCPBK
* THIS COPYBOOK - KW8M0U0 - DEFINES THE INTERNAL REPRESENTATION OFCADKCPBK
* SEGMENT KW8M0U0. CADKCPBK
* ----------------------------------------------------------------CADKCPBK
* Loss Occurrence Data Segment CADKCPBK
* CADKCPBK
* CADKCPBK
* CREATED ON 2002-11-08 AT 00:22:17 CADKCPBK
*-----------------------------------------------------------------CADKCPBK
03 K-W8M0-LINK-DATA. CADKCPBK
05 K-W8M0-LENGTH PIC 9(9) COMP CADKCPBK
VALUE 00585. CADKCPBK
88 K-W8M0-LENGTH-VALUE VALUE 00585. CADKCPBK
05 K-W8M0-LINKAGE-ID. CADKCPBK
07 K-W8M0-LINKAGE-NAME PIC X(08) CADKCPBK
VALUE 'KW8M0U0'. CADKCPBK
88 K-W8M0-KW8M0U0 VALUE 'KW8M0U0'. CADKCPBK
07 K-W8M0-CABS-VERSION PIC X(08) CADKCPBK
VALUE 'R03V00'. CADKCPBK
88 K-W8M0-R03V00 VALUE 'R03V00'. CADKCPBK
05 K-W8M0-SEGMENT-DATA. CADKCPBK
07 K-W8M0-RETURN-CODE PIC X(01). CADKCPBK
88 K-W8M0-ERROR-OCCURRED VALUE 'E'. CADKCPBK
88 K-W8M0-NORMAL-RETURN VALUE SPACE. CADKCPBK
07 K-W8M0-FUNCTION-CODE-W8M0 PIC X(02). CADKCPBK
88 K-W8M0-VALID-FUNCTION VALUE CADKCPBK
'A' CADKCPBK
'ZB' CADKCPBK
'D' CADKCPBK
'ZA' CADKCPBK
'NC' CADKCPBK
'RO' CADKCPBK
'U' CADKCPBK
. CADKCPBK
88 K-W8M0-ADD CADKCPBK
VALUE 'A'. CADKCPBK
88 K-W8M0-DECLINE CADKCPBK
VALUE 'ZB'. CADKCPBK
88 K-W8M0-DELETE CADKCPBK
VALUE 'D'. CADKCPBK
88 K-W8M0-FINALISE CADKCPBK
VALUE 'ZA'. CADKCPBK
88 K-W8M0-NOCLAIM CADKCPBK
VALUE 'NC'. CADKCPBK
88 K-W8M0-REOPEN CADKCPBK
VALUE 'RO'. CADKCPBK
88 K-W8M0-UPDATE CADKCPBK
VALUE 'U'. CADKCPBK
07 K-W8M0-DATA-AREA. CADKCPBK
09 K-W8M0-TIMESTAMP-UPDATED PIC X(00026). CADKCPBK
09 K-W8M0-USER-UPDATED PIC X(00008). CADKCPBK
09 K-W8M0-OCCURRENCE-NUMBER PIC X(00010). CADKCPBK
09 K-W8M0-OCCURRENCE-STATUS PIC X(00001). CADKCPBK
88 K-W8M0-ACCEPTED VALUE CADKCPBK
'A'. CADKCPBK
88 K-W8M0-DECLINED VALUE CADKCPBK
'D'. CADKCPBK
88 K-W8M0-ENTRY-ONLY VALUE CADKCPBK
'E'. CADKCPBK
88 K-W8M0-FINALISED VALUE CADKCPBK
'F'. CADKCPBK
88 K-W8M0-NO-CLAIM VALUE CADKCPBK
'N'. CADKCPBK
88 K-W8M0-OTHER-INSURER VALUE CADKCPBK
'N'. CADKCPBK
88 K-W8M0-PENDING VALUE CADKCPBK
'E'. CADKCPBK
88 K-W8M0-REOPENED VALUE CADKCPBK
'R'. CADKCPBK
09 K-W8M0-DATE-OCCURRED PIC X(00010). CADKCPBK
09 K-W8M0-TIME-OCCURRED PIC X(00008). CADKCPBK
09 K-W8M0-ACCIDENT-CODE PIC X(00005). CADKCPBK
09 K-W8M0-DECLINED-CODE PIC X(00005). CADKCPBK
09 K-W8M0-DATE-REPORTED PIC X(00010). CADKCPBK
09 K-W8M0-DATE-ENTERED PIC X(00010). CADKCPBK
09 K-W8M0-DATE-RECEIVED PIC X(00010). CADKCPBK
09 K-W8M0-DATE-FINALISED PIC X(00010). CADKCPBK
09 K-W8M0-REOPEN-DATE PIC X(00010). CADKCPBK
09 K-W8M0-REOPEN-REASON PIC X(00005). CADKCPBK
09 K-W8M0-ASSESSOR-REPORT PIC X(00001). CADKCPBK
09 K-W8M0-POLICE-REPORT PIC X(00001). CADKCPBK
09 K-W8M0-REVIEWER PIC X(00008). CADKCPBK
09 K-W8M0-EXAMINER PIC X(00008). CADKCPBK
09 K-W8M0-ESTIMATED-LOSS-DISP. CADKCPBK
11 K-W8M0-ESTIMATED-LOSS PIC S9(09) CADKCPBK
COMP-3. CADKCPBK
09 K-W8M0-CLAIM-COMPANY PIC X(00003). CADKCPBK
09 K-W8M0-CLAIM-COUNTRY PIC X(00003). CADKCPBK
09 K-W8M0-CLAIM-STATE PIC X(00003). CADKCPBK
09 K-W8M0-CLAIM-BRANCH PIC X(00003). CADKCPBK
09 K-W8M0-CLAIM-REGION PIC X(00003). CADKCPBK
09 K-W8M0-TIMESTAMP-ENTERED PIC X(00026). CADKCPBK
09 K-W8M0-USER-ENTERED PIC X(00008). CADKCPBK
09 K-W8M0-AGENT-REVIEWED-IND PIC X(00001). CADKCPBK
09 K-W8M0-SIU-HANDLER PIC X(00008). CADKCPBK
09 K-W8M0-SIU-REFER-REASON PIC X(00030). CADKCPBK
09 K-W8M0-SIU-REFERRAL-IND PIC X(00001). CADKCPBK
09 K-W8M0-LINE-OF-BUSINESS PIC X(00005). CADKCPBK
09 K-W8M0-PRODUCT-CODE PIC X(00005). CADKCPBK
09 K-W8M0-NUM-OF-VEHICLES-DISP. CADKCPBK
11 K-W8M0-NUM-OF-VEHICLES PIC S9(03) CADKCPBK
COMP-3. CADKCPBK
09 K-W8M0-PERCENT-OF-FAULT PIC X(00001). CADKCPBK
88 K-W8M0-AT-FAULT-1-50 VALUE CADKCPBK
'3'. CADKCPBK
88 K-W8M0-AT-FAULT-51-100 VALUE CADKCPBK
'4'. CADKCPBK
88 K-W8M0-FAULT-UNKNOWN VALUE CADKCPBK
'0'. CADKCPBK
88 K-W8M0-NOT-AT-FAULT VALUE CADKCPBK
'2'. CADKCPBK
09 K-W8M0-DRIVER-UAR PIC X(00003). CADKCPBK
09 K-W8M0-TYPE-OF-ACCIDENT PIC X(00001). CADKCPBK
09 K-W8M0-CROSS-INSURED PIC X(00001). CADKCPBK
09 K-W8M0-LITIGATION-FLAG PIC X(00001). CADKCPBK
09 K-W8M0-LOSS-CATEGORY PIC X(00002). CADKCPBK
88 K-W8M0-BICYCLIST VALUE CADKCPBK
'01'. CADKCPBK
88 K-W8M0-COLLISION-CSR VALUE CADKCPBK
'02'. CADKCPBK
88 K-W8M0-COLLISION-DIV VALUE CADKCPBK
'03'. CADKCPBK
88 K-W8M0-COMPREHNSVE-CSR VALUE CADKCPBK
'04'. CADKCPBK
88 K-W8M0-COMPREHNSVE-DIV VALUE CADKCPBK
'05'. CADKCPBK
88 K-W8M0-GLASS-ONLY VALUE CADKCPBK
'06'. CADKCPBK
88 K-W8M0-GLASS-ONLY-FTP VALUE CADKCPBK
'07'. CADKCPBK
88 K-W8M0-MOTORCYCLIST VALUE CADKCPBK
'08'. CADKCPBK
88 K-W8M0-PEDESTRIAN VALUE CADKCPBK
'09'. CADKCPBK
88 K-W8M0-RECORD-ONLY VALUE CADKCPBK
'10'. CADKCPBK
88 K-W8M0-TOTAL-THEFT VALUE CADKCPBK
'11'. CADKCPBK
88 K-W8M0-TOW-AND-LABOR VALUE CADKCPBK
'12'. CADKCPBK
88 K-W8M0-TOW-AND-LABOR-FTP VALUE CADKCPBK
'13'. CADKCPBK
88 K-W8M0-UIMBI VALUE CADKCPBK
'14'. CADKCPBK
88 K-W8M0-UMBI VALUE CADKCPBK
'15'. CADKCPBK
09 K-W8M0-FIRE-REPORT PIC X(00001). CADKCPBK
09 K-W8M0-AT-FAULT-DATE PIC X(00010). CADKCPBK
09 K-W8M0-AMOUNT-OF-BILL PIC X(00005). CADKCPBK
09 K-W8M0-VENDOR PIC X(00050). CADKCPBK
09 K-W8M0-INVOICE-NUMBER PIC X(00050). CADKCPBK
09 K-W8M0-AT-FAULT-REQUEST PIC X(00001). CADKCPBK
09 K-W8M0-POLICY-STATE PIC X(00003). CADKCPBK
09 K-W8M0-ACTION-CODE-W8M0 PIC X(00002). CADKCPBK
88 K-W8M0-CRRCTN VALUE CADKCPBK
'EC'. CADKCPBK
09 K-W8M0-LAST-ASSIGN-DATE PIC X(00010). CADKCPBK
09 K-W8M0-POST-CODE PIC X(00009). CADKCPBK
07 K-W8M0-OTHER-DATA. CADKCPBK
09 K-W8M0-ERROR-DATA. CADKCPBK
11 K-W8M0-FUNCTION-CODE-W8M0-E PIC 999. CADKCPBK
11 K-W8M0-TIMESTAMP-UPDATED-E PIC 999. CADKCPBK
11 K-W8M0-USER-UPDATED-E PIC 999. CADKCPBK
11 K-W8M0-OCCURRENCE-NUMBER-E PIC 999. CADKCPBK
11 K-W8M0-OCCURRENCE-STATUS-E PIC 999. CADKCPBK
11 K-W8M0-DATE-OCCURRED-E PIC 999. CADKCPBK
11 K-W8M0-TIME-OCCURRED-E PIC 999. CADKCPBK
11 K-W8M0-ACCIDENT-CODE-E PIC 999. CADKCPBK
11 K-W8M0-DECLINED-CODE-E PIC 999. CADKCPBK
11 K-W8M0-DATE-REPORTED-E PIC 999. CADKCPBK
11 K-W8M0-DATE-ENTERED-E PIC 999. CADKCPBK
11 K-W8M0-DATE-RECEIVED-E PIC 999. CADKCPBK
11 K-W8M0-DATE-FINALISED-E PIC 999. CADKCPBK
11 K-W8M0-REOPEN-DATE-E PIC 999. CADKCPBK
11 K-W8M0-REOPEN-REASON-E PIC 999. CADKCPBK
11 K-W8M0-ASSESSOR-REPORT-E PIC 999. CADKCPBK
11 K-W8M0-POLICE-REPORT-E PIC 999. CADKCPBK
11 K-W8M0-REVIEWER-E PIC 999. CADKCPBK
11 K-W8M0-EXAMINER-E PIC 999. CADKCPBK
11 K-W8M0-ESTIMATED-LOSS-E PIC 999. CADKCPBK
11 K-W8M0-CLAIM-COMPANY-E PIC 999. CADKCPBK
11 K-W8M0-CLAIM-COUNTRY-E PIC 999. CADKCPBK
11 K-W8M0-CLAIM-STATE-E PIC 999. CADKCPBK
11 K-W8M0-CLAIM-BRANCH-E PIC 999. CADKCPBK
11 K-W8M0-CLAIM-REGION-E PIC 999. CADKCPBK
11 K-W8M0-TIMESTAMP-ENTERED-E PIC 999. CADKCPBK
11 K-W8M0-USER-ENTERED-E PIC 999. CADKCPBK
11 K-W8M0-AGENT-REVIEWED-IND-E PIC 999. CADKCPBK
11 K-W8M0-SIU-HANDLER-E PIC 999. CADKCPBK
11 K-W8M0-SIU-REFER-REASON-E PIC 999. CADKCPBK
11 K-W8M0-SIU-REFERRAL-IND-E PIC 999. CADKCPBK
11 K-W8M0-LINE-OF-BUSINESS-E PIC 999. CADKCPBK
11 K-W8M0-PRODUCT-CODE-E PIC 999. CADKCPBK
11 K-W8M0-NUM-OF-VEHICLES-E PIC 999. CADKCPBK
11 K-W8M0-PERCENT-OF-FAULT-E PIC 999. CADKCPBK
11 K-W8M0-DRIVER-UAR-E PIC 999. CADKCPBK
11 K-W8M0-TYPE-OF-ACCIDENT-E PIC 999. CADKCPBK
11 K-W8M0-CROSS-INSURED-E PIC 999. CADKCPBK
11 K-W8M0-LITIGATION-FLAG-E PIC 999. CADKCPBK
11 K-W8M0-LOSS-CATEGORY-E PIC 999. CADKCPBK
11 K-W8M0-FIRE-REPORT-E PIC 999. CADKCPBK
11 K-W8M0-AT-FAULT-DATE-E PIC 999. CADKCPBK
11 K-W8M0-AMOUNT-OF-BILL-E PIC 999. CADKCPBK
11 K-W8M0-VENDOR-E PIC 999. CADKCPBK
11 K-W8M0-INVOICE-NUMBER-E PIC 999. CADKCPBK
11 K-W8M0-AT-FAULT-REQUEST-E PIC 999. CADKCPBK
11 K-W8M0-POLICY-STATE-E PIC 999. CADKCPBK
11 K-W8M0-ACTION-CODE-W8M0-E PIC 999. CADKCPBK
11 K-W8M0-LAST-ASSIGN-DATE-E PIC 999. CADKCPBK
11 K-W8M0-POST-CODE-E PIC 999. CADKCPBK
09 K-W8M0-TOKEN-DATA. CADKCPBK
11 K-W8M0-OCCURRENCE-NUMBER-T PIC X(00010). CADKCPBK
*---------------------------------------------------------------- CADKCPBK
* END OF COPYBOOK KW8M0U0 CADKCPBK
*---------------------------------------------------------------- CADKCPBK

Here I would like to remove the word "CADKCPBK" from each line and all the comments starts with '*'.
The reason I am avoiding the line starts with "'" is, if I see the line starts with "88" , I am merging the value of that line from the next line.
that logic is handled in the following portion of the code,
else if(levelNumber.equals("88"))
{
//System.out.println("Inside condition 2");
temp = inLine + " " + in.readLine().trim();
outLine = temp;
}

Ultimately I have to extract all the copy-book identifiers out of comments and unwanted words. The unwanted words are all coming, while do the FTP fromt he mainframe machine.
Thanks for you reply.
Shanmugam.
Shanmugam Muthukumarasamy
Ranch Hand

Joined: Jan 11, 2003
Posts: 83
Thank you very much jason adam !!!, I tried to flush and close the out buffer. It worked out.
Thanks a lot.
Shanmugam
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Great, glad to know things are working!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Not able to write the whole content