MIDRANGE dot COM Mailing List Archive



Home » JAVA400-L » October 2005

RE: IFSFileWriter problem: unusual output in IFS file



fixed

Thanks everyone for the responses. It was indeed a CCSID problem. I dug into 
the JTOpen Javadocs and found an alternative constructor that accepts file 
name, append flag, share option, and ccsid. Using this constructor with a value 
of 819 for the CCSID did the trick. The revised (and working) code is:

public static void main(String[] args) {
    AS400 system = new AS400("mysystem", "myname", "mypassword");
    IFSFile file = new IFSFile(system, "/home/mydir/writeifs_test.txt");
    try {
        PrintWriter myWriter = new PrintWriter(new BufferedWriter(new 
IFSFileWriter(file, true, -2, 819)));
          myWriter.println("here is the second test");
          myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
    }//end-try-catch
}//end-main

The true means append to the file if it exists, the -2 means share writers with 
other users, and 819 is the ASCII CCSID.  

Thanks again.
Kelly

-----Original Message-----
From: java400-l-bounces+kcookson=dotfoods.com@xxxxxxxxxxxx
[mailto:java400-l-bounces+kcookson=dotfoods.com@xxxxxxxxxxxx]On Behalf
Of Joe Pluta
Sent: Wednesday, October 19, 2005 2:14 PM
To: 'Java Programming on and around the iSeries / AS400'
Subject: RE: IFSFileWriter problem: unusual output in IFS file


> From: Kelly Cookson
> 
> We want to write text strings to a file in the IFS. We can write to
the
> IFS file, but each letter is separated what looks like a tab, and the
end-
> of-line characters are unusual.

Whenever you see the "spaces" between characters, that's a good
indication that you're looking at a Unicode file with a non-Unicode
enabled viewer.  Unicode encodes every character as two bytes, with
standard ASCII text being the normal hex value preceded by x'00'.  For
example, upper-case 'A' ends up as x'00'-x'41'.  ASCII text in general
ends up with x'00' between every character, which shows up as dots or
boxes depending on the viewer.

To fix this, you need to either convert the file from Unicode to
standard ASCII text, or create it as ASCII in the first place.  I'm not
certain how to assign the CCSID on an IFSFileWriter object; I know you
can do it with an IFSTextFileOutputStream.

Joe






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact