Dave's Brain

Browse - Programming Tips - How do I read the content from a Part?

Date: 2014aug26
Language: Java
Platform: Servlet

Q.  How do I read the content from a Part?

A.  Here's method for that:

String readContent(Part part) throws IOException { InputStream is = part.getInputStream(); final int n = is.available(); byte [] bytes = new byte[n]; // Allocate room is.read(bytes, 0, n); return new String(bytes, "UTF-8"); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.