one update now:
Now i am able to display normal English spool files properly in console without any junk characters using below code.PrintParameterList prtParm = new PrintParameterList();prtParm.setParameter(PrintObject.ATTR_MFGTYPE,"*WSCST" );prtParm.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT,"/QSYS.LIB/QWPDEFAULT.WSCST");PrintObjectTransformedInputStream inpStream =null;inpStream = splf.getTransformedInputStream(prtParm);byte[] buf = new byte[32767];StringBuffer buffer = new StringBuffer();int bytesRead = 0;do { bytesRead = inpStream.read( buf ); if (bytesRead > 0) { buffer.append(new String(buf,0,bytesRead)); } } while ( bytesRead != -1 );System.out.println("buffer: " + buffer); // displaying fine
But still arabic characters are displayed as junk characters. eg: û×ÑPlease help.
Thanks
yash
From: "yasho laks" <yasholaks@xxxxxxxxxxxxxx>
Sent: Wed, 15 May 2013 12:53:56
To: "java400-l@xxxxxxxxxxxx" <java400-l@xxxxxxxxxxxx>
Subject: Re: View As400 spool file - junk characters issue
Hi Thanks for fast response.
The"isr" is the same "inputStream".Please let me know how to find the ccsid of each spooled file since there is no java api for that.
Also if create the below spool file instance "splf" for spool file having some arabic characters it is reading and displaying as ??? ?? in console whereever that arabic char comes.How to resolve this issue? how to display the arabic characters properly?
Please give some inputs to display arabic characters properly.
Thanks in advance.yash
From: Dan Kimmel &lt;dkimmel@xxxxxxxxxxxxxxx>;
Sent: Tue, 14 May 2013 20:37:39
To: Java Programming on and around the IBM i &lt;java400-l@xxxxxxxxxxxx>;
Subject: Re: View As400 spool file - junk characters issue
Yash,
First, this is really hard to read. Here's what I got out of it:
static BufferedReader d = null;
static PrintObjectInputStream inputStream = null;
AS400 sys = new AS400("sysName", "yas", "n123");
System.out.println("ccsid::"+sys.getCcsid()); // 37
SpooledFile splf = new SpooledFile( sys, // AS400
"QPJOBLOG", // splf name
1, // splf number
"QPADEV00H0", // job name
"YAS", // job user
"149099" ); // job number
inputStream = splf.getInputStream(null);
d = new BufferedReader(new InputStreamReader(isr,"CP037"));
String data ="";
while((data = d.readLine() )!=null)
{ System.out.println (data);
}
I don't see where "isr" is coming from. The first parameter of new InputStreamReader() should be inputStream, I think. The second parameter is code page which you have correctly, provided the spooled file actually is encoded US English EBCDIC.
Is your spooled file actually in US English EBCDIC (ccsid 37)?
With SpooledFile.getInputStream(null) you get pretty raw data. In other words, you'll get control characters as well as text. Not all of those control characters are going to translate well into java Unicode, which is what happens when you build an InputStreamReader over a byte stream.
So your non-translate-able characters (?) or incorrectly translated characters ({ etc) could come either in the SpooledFile.getInputStream(null) or in the use of the InputStreamReader. I believe that getInputStream(null) is going to attempt to translate the SpooledFile from the whatever CCSID it is encoded into the CCSID of the IBMi service job that reads it.
Note that when you getCcsid from the AS400 object, you get the default CCSID of the box, not necessarily the CCsid that the spooled file is encoded. You can use splf.getCcsid() for that.
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of yasho laks
Sent: Tuesday, May 14, 2013 5:21 AM
To: java400-l@xxxxxxxxxxxx
Subject: View As400 spool file - junk characters issue
Hi
I am trying to view my AS400 spooled file through java code using below snippet.Its displaying the spool file in console but with some junk characters(?{ etc) also with it.Please let me know if there is anything wrong in below code.
static BufferedReader d = null;static PrintObjectInputStream inputStream = null;
&amp;nbsp;AS400 sys = new AS400("sysName", "yas", "n123"); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println("ccsid::"+sys.getCcsid()); // 37 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SpooledFile splf = new SpooledFile( sys, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// AS400 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"QPJOBLOG", &amp;nbsp; &amp;nbsp; &amp;nbsp; // splf name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // splf number &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"QPADEV00H0", &amp;nbsp; &amp;nbsp;// job name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;n
bsp; &amp;nbsp;"YAS", &amp;nbsp; &amp;nbsp; &amp;nbsp;// job user &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"149099" ); &amp;nbsp; // job number&amp;nbsp;inputStream = splf.getInputStream(null);d = new BufferedReader(new InputStreamReader(isr,"CP037"));
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String data =""; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while((data = d.readLine() )!=null) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println (data); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
Thanks in advance.yash
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.