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

  • SEARCH
  • Home
  • 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 7640131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:35:46+00:00 2026-05-31T08:35:46+00:00

I have a webapplication which allows to upload binary files. I have to parse

  • 0

I have a webapplication which allows to upload binary files. I have to parse them and save the content 1:1 into a String and then into the database.

When I use uuencode on a unix machine to encode the binary file, then it works. Is there a way to do this automatically in java?

if (isMultipart) {

            //Create a new file upload handler
            ServletFileUpload upload = new ServletFileUpload();

            //Parse the request
            FileItemIterator iter = upload.getItemIterator(request);

            while (iter.hasNext()) {
                FileItemStream item = iter.next();
                String name = item.getFieldName();

                InputStream stream = item.openStream();

                if (!item.isFormField()) {

                    BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
                    String line;
                    licenseString = "";

                    while ((line = reader.readLine()) != null) {
                        System.out.println(line);

                        // Generate License File
                        licenseString += line + "\n";
                    }
                }
            }
            session.setAttribute("licenseFile", licenseString);
            System.out.println("adding licensestring to session. ");
        }

It works of course for all non-binary files uploaded. How can I extend it to support binary files?

  • 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-05-31T08:35:47+00:00Added an answer on May 31, 2026 at 8:35 am
    // save to file
    // =======================================
    InputStream is = new BufferedInputStream(item.openStream());
    BufferedOutputStream output = null;
    
    try {
        output = new BufferedOutputStream(new FileOutputStream("temp.txt", false));
        int data = -1;
        while ((data = is.read()) != -1) {
            output.write(data);
        }
    } finally {
        is.close();
        output.close();
    }
    
    // read content of file
    // =======================================
    System.out.println("content of file:");
    try {
        FileInputStream fstream = new FileInputStream("temp.txt");
    
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String line;
    
        licenseString = "";
        String strLine;
        while ((strLine = br.readLine()) != null)   {
              System.out.println(javax.xml.bind.DatatypeConverter.printBase64Binary(strLine.getBytes()));
              licenseString += javax.xml.bind.DatatypeConverter.printBase64Binary(strLine.getBytes()) + "\n";
        }                                           
    } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

BACKGROUND: I have built a web application for a client which allows them to
I have a web application (Java, Websphere, JSP) which allows co-workers to register visitors
I have two webapplication, one is a simple authenticationsite which can authenticate the logged
I'm developing an ASP.NET forms webapplication using C#. I have a method which creates
I have a web application which provides Excel files via IE 7. It requests
I have a PHP web application which uses a MySQL database for object tagging,
I have a web application in which a user has to upload images to
I have a web application that has a dynamic javascript calendar, which allows users
I have a question web application which allows users to ask questions on specific
I like to write a template system in Python, which allows to include files.

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.