So, here is the code I am using with your package.. it still converts a
few characters incorrectly. What am I doing wrong. Any help is greatly
apprecaited.
Specifically
81 -> 3F
8D -> 3F
8F -> 3F
90 -> 3F
public class Test
{
public static final String zipCharset = "ISO-8859-1";
public static final String utf8 = "ISO-8859-1";
public static void main(String[] args)
{
String in = readFile(new File("c:\\in.zip"));
Base64u base64u = new Base64u();
base64u.setLineLength( 72 ); // default
String enc = base64u.encode(in.getBytes());
// System.out.println(enc);
String dec = new String(base64u.decode(enc));
writeToFile(new File("c:\\out.zip"), dec);
}
/*
* Write output string to a file, encode if wanted
*/
public static void writeToFile(File f, String str) {
try {
OutputStream fos;
Writer out;
fos = new FileOutputStream(f);
out = new OutputStreamWriter(fos);
out.write(str);
out.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
/*
* Read input string from a file, decode if wanted
*/
public static String readFile(File f) {
StringBuffer buffer = new StringBuffer();
FileInputStream fis;
InputStreamReader isr;
try {
fis = new FileInputStream(f);;
isr = new InputStreamReader(fis);
Reader in = new BufferedReader(isr);
int ch;
while ((ch = in.read()) > -1) {
buffer.append((char) ch);
}
in.close();
return buffer.toString();
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
}