First, Java Properties
files are always stored in ISO8859-1. That's the specification, and the Properties.load() and store() methods will use that encoding. (Refer to the javadoc for java.util.Properties)
Second, Java Properties objects (in memory), are always java.lang.String (in Unicode). So, it doesn't make sense to try to convert the String key and value to some other encoding when you are trying to create the Properties object.
The following code will only serve to create a garbage String:
new String("A1".getBytes(), ZUtil.getDefaultPlatformEncoding())
- first, the String "A1" (in Unicode) is converted to bytes in the default file encoding (ISO8859-1)
- next, you create a String from ISO8859-1 bytes, but using IBM-1047 (EBCDIC) encoding.
If you really want to dump properties to a dataset in EBCDIC from a Properties object, you will have to use the Properties.store() method to store ISO8859-1 bytes onto a Stream and then convert that stream to EBCDIC. Loading properties from EBCDIC will have to reverse the process.
Something like:
Properties props = new Properties();
props.put("A", "B");String zDD = ZFile.allocDummyDDName();
ZFile.bpxwdyn("alloc fi(" + zDD + ") da(" + zName + ") new reuse recfm(f,b) dsorg(ps) lrecl(256) catalog msg(wtp)");
BufferedWriter writer = FileFactory.newBufferedWriter("//DD:" + zDD);
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
props.store(bos, "example properties");
String propertiesFileAsString = new String(bos.toByteArray(), "ISO8859-1");
writer.append(propertiesFileAsString);
} finally {
try {
writer.close();
} catch(Exception ignore) {}
ZFile.bpxwdyn("free fi(" + zDD + ") msg(wtp)");
}