I am trying to read a spool file on AS400 thru java and am trying to
convert the retrieved bytes into String. It seems it is reading some
junk characters(may be spaces ) and than starts reading the actual
data. It also prints "?{.' at the start of each line. It doesn't read
the data till the end of file and stops half way thru....
Here is the code snippet that I am using
InputStream in = null;
SpooledFile splf= new SpooledFile(....);
in = splf.getInputStream();
byte[] byteArr = new byte[in.available()];
in.read(byteArr);
String output = new String(byteArr,"Cp037");
It gives me the same output even if I use BufferedReader.
InputStreamReader inp = new InputStreamReader(in,"Cp037");
BufferedReader reader = new BufferedReader(inp);
String output = reader.readLine();
I tried using AS400Text class also....
AS400Text text = new AS400Text(byteArr.length,"Cp037");
String output = ((String)text.toObject(byteArr));
All of them give the same output. Is it something to do with the
encoding type ??
If I don't use "Cp037" encoding type, it prints all junk....
Any ideas where I am wrong...??
Thanks in advance....I am new in this area n any help would be
appreciated...
Thanks,
nis
The code page to use really depends upon what the data is encoded in in
the spooled file. If your i5/OS is using the defaults for US English,
37 would be the correct choice.
The CHRID attribute of the spooled file might have the encoding of the
data, but typically it doesn't and just has special value for *DEVD.
In V5R4, a new spooled file attribute was added...the attribute is a
capture of the job's CCSID at the time the spooled file was created. It
might represent the encoding of the data and it might not...since the
encoding of the data is really under the control of the application
generating the spooled file.
--
Rodney A Johnson
Technical Team Lead for i5/OS (AS/400) Spool
Dept GJC
IBM Rochester, Minnesota
The contents of this message express only the sender's opinion.
This message does not necessarily reflect the policy or views of
my employer, IBM. All responsibility for the statements
made in this Usenet posting resides solely and completely with the
sender.
You can also use the SCS conversion..... check out
http://www.brooksnet.com/as400-printing.html and the SCS page at
http://lpd.brooksnet.com/scstoascii-translation.html for your
translations...
Hope this helps,
FT
But I am totally new to this world of AS400, so plz pardon me if my
questions sound silly.
I checked the type for the spool file and it indeed is SCS format. Now,
when I try to print out the bytes thru a for loop, I get kinda
following signed output.
52, -60, 1, 0, 43, -46, 3, 69, -1, 0, 43, -46, 4, 76, 0, 3, 0, 43,
-46, 4, 13, 0, 0, 0, 43, -46, 10,
-123, 1, 1...etc
I am not sure what this raw data represents out of the spool
file.....but when I print it after converting it to string(as mentioned
before)....except for 2 lines in the start and a couple of character
for each line in the beginning ...everything else gets printed.
I am all confused as to what it is going on..
I tried to get some info regarding SCS, but as per my understaning
there is SCS5256Writer, etc available for writer thingy, but what do I
do to read it.
Waiting for your input,
Thanks,
Nisarg.
--
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'
thanks for d replies...
I got d solution ...i need to use printparameterlist and
getTransformedInputStream() to extract text out of spool file.
The encoding thingy still bounces my head off.
Thanks,
Nisarg.
If you look at it another way..A spool file is data more or less ready
to be printed. If you printed plain text on a windows system using the
printer driver but to a file, then try reading the output from that you
would have quite a good time. On old dot matrix printers the output for
just 1 line of text could be a couple of kilobyes.
Jonathan.
Thanks,
Nisarg.