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");
    } catch (Exception e) {

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.

-----Original Message-----
[]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
> IFS file, but each letter is separated what looks like a tab, and the
> 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.


This thread ...

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