× 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.



I'm encountering a strange problem here. Below is a <clip> of my code
in a java class:

<clip>
String str;
String osName = System.getProperty("os.name");
if (osName.equals("OS/400")) {
str = bao.toString("Cp037");
}
else
{
str = bao.toString();
}
</clip>


For some reasons, if this class is instantiate from RPG program, it
works correctly (Str variable will contain readable context). But if
this class is instantiate from a EJB application, that is running on an
iseries, the str variable will contain non-readable text. It is
obviously caused by bao is in EBCDIC format when running in RPG but it
is in ASCII format when running from EJB.

Any idea how I can resolve this issue?

Below is the complete code of the class:
package com.arch.boss.util;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.Arrays;
import com.arch.boss.log.Log;

class StreamGobbler extends Thread
{
InputStream is = null;
ByteArrayOutputStream bao = null;
List<String> listString = null;

StreamGobbler(InputStream is, OutputStream os)
{
this.is = is;
this.bao = (ByteArrayOutputStream) os;
}

StreamGobbler(InputStream is, List<String> listString)
{
this.is = is;
this.bao = new ByteArrayOutputStream();
this.listString = listString;
}

public void run()
{
try {

// read the inputStream and place the result in the
outputStream
int result = is.read();
while(result != -1) {
byte b = (byte)result;
bao.write(b);
result = is.read();
}

is.close();

// if caller wants it in List String format, convert

// the bytearray into stream
if (listString != null) {
String str;
String osName =
System.getProperty("os.name");
if (osName.equals("OS/400")) {
Log.category.debug( "StreamGobbler(Before): " +
bao.toString());
str = bao.toString("Cp037");
Log.category.debug( "StreamGobbler(After): " +
bao.toString());
}
else
{
Log.category.debug( "StreamGobbler: " +
bao.toString());
str = bao.toString();
}

listString.addAll(Arrays.asList(str.split("\n")));
}

}
catch (Exception ex) {
Log.category.debug("Error Occured When attempting to get ssh
Key --", ex);
}
}
}

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.