- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: BufferedWriter and Stringbuffer Issue- J2SDK.v...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2007 08:37 PM
05-20-2007 08:37 PM
BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
It then converts the string buffer to a string and outputs that to a file using bufferedwriter.write
However it causes line breaks in the file where it shouldn't and I dont know why.
Are there any known issues with bufferedwriter in this java version?
What could be causing these fairly random line breaks?
Its also using Fast VM (build 1.4.1-2, build J2SDK.v.1.4.1.
Can Fast VM run in different modes that might cause this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 09:59 AM
05-21-2007 09:59 AM
Re: BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
"fairly random"? Does this mean they're unrelated to the strings being appended?
What is the record format of your file? (DIR/FULL) Can you check the binary contents of the file around the apparent line breaks (use DUMP and compare with DUMP/RECORD). It may also be interesting to see the binary contents of your string buffer and again after it's been converted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 08:29 PM
05-21-2007 08:29 PM
Re: BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
Sometimes when I run it there are no bad line breaks and other times there would be one every 800 or so lines.
import java.util.*;
import java.util.*;
import java.io.*;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.*;
class Test3 {
public static void main(String[] args) throws IOException {
String contents = "";
int lSize = 0;
FileWriter fw = new FileWriter("test10.txt");
BufferedWriter bw = null;
StringBuffer strb = new StringBuffer();
strb.append("allow_from");
strb.append(" ");
strb.append("dq@dq.com");
strb.append("\n");
String bufferString =strb.toString();
try {
bw = new BufferedWriter(fw);
// Now put together the contents of the file:
for(int i=1;i<60000;i++)
{
bw.write(i+ " "+bufferString);
}
catch(IOException ioe) {
throw ioe;
}
finally {
if(bw!=null) bw.close();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 09:21 PM
05-21-2007 09:21 PM
Re: BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
I tried running it on windows and then I sent the program and the text file I had been writing to on windows over to the open vms machine.
Then when I ran it on open vms there were the line breaks on line 988 and 1303, line 1618 etc. like this (note I havent put in all the lines cos it'd take up to0 much space)
987 allow_from dq@dq.com
988 allow
_from dq@dq.com
989 allow_from dq@dq.com
1301 allow_from dq@dq.com
1302 allow_from dq@dq.com
1303 allow_from dq@dq.c
om
1304 allow_from dq@dq.com
1305 allow_from dq@dq.com
1618 allow_from dq@dq.com
1619 allow_from dq@dq.com
1933 allow_from dq@dq.com
1
934 allow_from dq@dq.com
1935 allow_from dq@dq.com
1936 allow_from dq@dq.com
2248 allow_from dq@dq.com
224
9 allow_from dq@dq.com
2250 allow_from dq@dq.com
so it does that every 300 lines or so and all other lines seem ok.
It seems to be because I sent a text file over from windows to open vms and it got corrupted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 10:27 PM
05-21-2007 10:27 PM
Re: BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
First, welcome to the VMS forum.
I tested your program with a different version of java (Classic VM (build 1.5.0-3, 03/01/2007-14:39, native threads, jit) and Fast VM (build 1.5.0-3, build J2SDK.v.1.5.0:03/01/2007-21:16, native threads, ji
t_150)). I cant reproduce the error.
Was the test10.txt a new file or only a new version of an existing file? Java (read as C) keeps the attributes of the existing file.
Could you post the DIR/FULL output as John suggested.
A quick check to line breaks you posted gives me the numbers:
first break at character position 24576 (0x6000)
second break at character position 32768 (0x8000)
The second is intresting 32767 is the maximal record size for many sequential file formats.
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 11:07 PM
05-21-2007 11:07 PM
Re: BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
TEST13.TXT;1 File ID: (739634,8,0)
Size: 252/255 Owner: [900013A,DAVIDQUINN]
Created: 22-MAY-2007 09:53:19.89
Revised: 22-MAY-2007 09:53:25.64 (1)
Expires:
Backup:
Effective:
Recording:
Accessed:
Attributes:
Modified:
Linkcount: 1
File organization: Sequential
Shelved state: Online
Caching attribute: Writethrough
File attributes: Allocation: 255, Extend: 0, Global buffer count: 0, No version limit
Record format: Variable length, maximum 0 bytes, longest 32767 bytes
Record attributes: Carriage return carriage control
RMS attributes: None
Journaling enabled: None
File protection: System:RWED, Owner:RWED, Group:RE, World:
Access Cntrl List: None
Client attributes: None
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2007 11:39 PM
05-21-2007 11:39 PM
Re: BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
However, that math does not work exacltly.
I would suggest that the line length of about 32, not the 26 shown.
To verify, check the output from $DUMP/RECORD=COUNT=1
You probably want to force a 'STREAM_LF' or STREAM output file. I don't know enough about the tools you used to help you force this. It could be a logical names, an open option, or the (non) presence of an existing file with the same name and the desired attributes.
To create such file, try:
$CREATE/FDL=SYS$INPUT:
RECORD; FORMAT STREAM_LF
$
What OpenVMS version?
It may be a problem which has been fixed?
Good luck,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2007 12:01 AM
05-22-2007 12:01 AM
Re: BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
You can try also to force stream_lf with:
$ DEFINE JAVA$CREATE_STMLF_FORMAT TRUE
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2007 01:06 AM
05-22-2007 01:06 AM
Re: BufferedWriter and Stringbuffer Issue- J2SDK.v.1.4.1
OpenVMS Alpha V7.3-1