title: Process binary file in Java using FileItemStream
body: <p>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. </p>
  
  <p>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?</p>
  
  <pre><code>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. ");
          }
  </code></pre>
  
  <p>It works of course for all non-binary files uploaded. How can I extend it to support binary files?</p>