× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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;
 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                                         &n
bsp;  "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);             }
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.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.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 on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.