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



Joe Sam,

Thanks for the checking into this further. Good stuff. It is nice to have so many methods for writing data to the 400 using Java.

Thanx again, PLA

Joe Sam Shirah wrote:

Hi Patrick,

   I finally got some time to test out RandomAccessFile and it does work.
I decided to combine it with Ivan's CCSID question, so I created a Unicode
capable file.  Here's the DDS - you'll probably need to put it in a text
editor to get everything to line up properly:
:

* Test UCS-2
A          R IT134882
*
A            OVNAME        30G              COLHDG('Name')
A                                           CCSID(13488)
*
A          K OVNAME
*

   One interesting thing is that the record ( max ) length is 60 because of
the 30 two-byte characters.

Here's the code I used with the path dummied up:

import java.io.*;

public class TestWriteAS400File
{
 public static void main(String[] args) throws Exception
 {

   RandomAccessFile raf =
     new RandomAccessFile(
       "/qsys.lib/alib.lib/aUniFile.file/aUniMbr.mbr", "rw" );

   raf.seek( 0 );
   raf.writeChars( "I want this to be record 1" );
   raf.seek( 60 );
   raf.writeChars( "I want this to be record 2" );
   raf.seek( 120 );
   raf.writeChars( "I want this to be record 3" );

   raf.close();
 } // end main

} // end class TestWriteAS400File

   Here's the hex dump output - again, you'll probably need to put it in a
text
editor to get everything to line up properly:

*...+....1....+....2....+....3....+....4....+....5....+....6
ñ   Ï / > È   È Ç Ñ Ë   È ?   Â Á   Ê Á Ä ? Ê À
040207060607020706060702070602060602070606060706020302020202
090007010E04000408090300040F000205000205030F0204000100000000

ñ   Ï / > È   È Ç Ñ Ë   È ?   Â Á   Ê Á Ä ? Ê À
040207060607020706060702070602060602070606060706020302020202
090007010E04000408090300040F000205000205030F0204000200000000

ñ   Ï / > È   È Ç Ñ Ë   È ?   Â Á   Ê Á Ä ? Ê À
040207060607020706060702070602060602070606060706020302020202
090007010E04000408090300040F000205000205030F0204000300000000


And here's an ISO 8859-1 table to confirm the values:


http://www.bbsinc.com/iso8859.html

 Since it's Unicode, which encompasses ISO 8859-1, the values are 2 bytes,
so for 'w', the value in the AS/400 file is 0077 ( \a0077 ) rather than just
0x77 as in the table.

   Also, the Java program clearly respected the file CCSID when running on
the AS/400 so I didn't have to specify the encoding.  I'm not sure ( and
probably won't take the time to find out until/unless I need it ) if that
would hold true if I were running a version on a client to write to the 400.
Normally I would expect system default encoding.


Joe Sam


Joe Sam Shirah -        http://www.conceptgo.com
conceptGO         -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?             http://www.jguru.com/faq/Java400






_______________________________________________ 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 thread ...


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.