I am a novice user trying to figure out how to use uuencode method. We have a form that allows only a single text file to be uploaded. Now it looks like only zip files will be uploaded. I am trying to include uuencode method to convert bytes to String so that we dont have to modify the rest of the code to accommodate the binary file.
Original code:
public void SettingUpload(File inputfile) {
this.inputfile = inputfile;
}
I changed it to
public void SettingUpload(File inputfile){
UUEncoder uuec = new UUEncoder();
try{
InputStream is = new FileInputStream(inputfile);
OutputStream os = new FileOutputStream(inputfile);
uuec.encodeBuffer(is, os);
this.inputfile = inputfile;
}catch (Throwable error) {
reportError(error, "Error converting zipfile");
}
}
When I tested it out, I got a java.io.EOFException. I grabbed the uuencoded file and manually uudecoded it. When I tried to unzip it,
bash1:~>unzip s6b0c9e663c74f72941bd8271a5fac3b.bin
Archive: s6b0c9e663c74f72941bd8271a5fac3b.bin
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
Edit:
I changed it to:
public void SettingUpload(File inputfile){
UUEncoder uuec = new UUEncoder();
try{
InputStream is = new FileInputStream(inputfile);
File OutputFile=new File("Output");
OutputFile.createNewFile();
OutputStream os = new FileOutputStream(OutputFile);
uuec.encodeBuffer(is, os);
this.OutputFile = OutputFile;
}catch (Throwable error) {
reportError(error, "Error converting zipfile");
}
}
and I get the following error:
cannot find symbol
symbol : variable OutputFile