Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:30:35+00:00 2026-06-12T06:30:35+00:00

I am a novice user trying to figure out how to use uuencode method.

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:30:37+00:00Added an answer on June 12, 2026 at 6:30 am

    As Haozhun has commented, you shouldn’t do this:

    InputStream is = new FileInputStream(inputfile); // Good
    OutputStream os = new FileOutputStream(inputfile); // Bad
    

    You should be outputting to a separate file, otherwise the first time you write, you will trash the original file.

    UPDATED with example

    This works fine for me…

    public static void main(String[] args) {
    
        File inputfile = new File("file/to/be/encoded");
        File outFile = new File("out.uue");
    
        UUEncoder uuec = new UUEncoder();
        InputStream is = null;
        OutputStream os = null;
        try {
    
            is = new FileInputStream(inputfile);
            os = new FileOutputStream(outFile);
            uuec.encodeBuffer(is, os);
    
        } catch (Exception error) {
            error.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (Exception e) {
            }
            try {
                os.close();
            } catch (Exception e) {
            }
        }
    
        File newFile = new File("decoded.jpg");
        UUDecoder decoder = new UUDecoder();
        try {
    
            is = new FileInputStream(outFile);
            os = new FileOutputStream(newFile);
            decoder.decodeBuffer(is, os);
    
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (Exception e) {
            }
            try {
                os.close();
            } catch (Exception e) {
            }
        }
    
    }
    

    Also, I would return the output file from you encode methods

    public void SettingUpload(File inputfile) throws IOException {
        UUEncoder uuec = new UUEncoder();
        File outFile = File.createTempFile("encoded", "uue");
        InputStream is = null;
        OutputStream os = null;
        try{
            is = new FileInputStream(inputfile);
            os = new FileOutputStream(outFile );
            uuec.encodeBuffer(is, os);
        } finally {
            try {
                is.close();
            } catch (Exception e) {
            }
                try {
            os.close();
            } catch (Exception e) {
            }
        }
        return outFile;
    }
    

    You should never suppress exceptions. How would the caller know if something has gone wrong?

    Also, if you open a stream, you’re responsible for closing it, so make sure you’re closing your streams.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a novice Python user trying to do something that I think should be
I'm trying to figure out how to use this directory_map function in CodeIgniter. See
I'm trying to figure out a user friendly way to pass messages to users
I have been looking around for a few hours trying to figure out how
I am trying to create a form that allows to assign multiple projectmembers to
I'm a novice MySQL user so could really use a little advice here. I've
I am a rather novice user of R and have come to appreciate the
I have a large nested list that I am trying to animate using jquery
I have a simple PHP script with a form that has two select fields,
I am trying to figure out how sessions work in Codeigniter. Reading the online

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.