|
Somehow System.getProperty("line.separator") doesn't work. Not sure why
yet.
"James Perkins" <jrperkinsjr@xxxxxxxxx> wrote in message
news:<mailman.3278.1253558564.1811.java400-l@xxxxxxxxxxxx>...
Just as an FYI, your newline character on Windows is \n\r. You best tograb
the System.getProperty("line.separator") property for your split.This is
Other than that I'm not sure I could really think of a better way.
where it get's tricky with the "run everywhere" type of thing.Obviously the
best way on the IBM i to run a command would be with the CommandCallclass,
but that won't work on Windows.want to
That being said, if you are already hard-coding something, you might
just use the CommandCall instead of the Runtime.getRuntime().exec()method.
Just a thought, not sure on the full scenario so this might not be anoption
at all.I
--
James R. Perkins
http://twitter.com/the_jamezp
On Mon, Sep 21, 2009 at 10:54, Lim Hock-Chai
<Lim.Hock-Chai@xxxxxxxxxxxxxxx>wrote:
I've solved this with this not so elegant solution: As you can see,
coversion ifbasically reading the data as ByteArray and does the EBCDIC
ArrayList<String>(Arrays.asList(str.split("\n")));the os.name = OS/400.
private static List<String> readStdio(InputStream is) throws
Exception {
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
List<String> rs = null;
int result = bis.read();
while(result != -1) {
byte b = (byte)result;
bao.write(b);
result = bis.read();
}
String str;
if (System.getProperty("os.name").equals("OS/400"))
str = bao.toString("Cp037");
else
str = bao.toString();
rs = new
to
return rs;
}
"hockchai Lim" <lim.hock-chai@xxxxxxxxxxxxxxx> wrote in message
news:<mailman.3218.1253552449.1811.java400-l@xxxxxxxxxxxx>...
I've created a class that will use the Runtime.getRuntime().exec
ifexecute
a command on iseries when instantiated. Once the command issucessfully
executed, it then reads the Process.getInputStream() to get theresult.
I've found that reading of the Process.getInputStream() works fine
instatiatedthe
class is instatiated from a PC. However, it failed to read
Process.getInputStream() data correctly when the class is
and,from
iseries. I then added some codes the print the read result in hex
result is
appearantly, when the class is instantiate from iseries, the
attempting tosent
back in EBCDIC encoding format and the BufferedReader is
soread
it as ASCII. Well, that ain't going to work :(.
Has anyone encountered this problem before? How can I resolve this
(JAVA400-L)that
this class can be run on both iseries and PC?--
This is the Java Programming on and around the iSeries / AS400
--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.
This is the Java Programming on and around the iSeries / AS400 (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 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.