List of usage examples for org.apache.commons.io IOUtils copy
public static void copy(Reader input, OutputStream output, String encoding) throws IOException
Reader
to bytes on an OutputStream
using the specified character encoding, and calling flush. From source file:demoalchemy.DemoCloudantClient.java
/** * @param args the command line arguments *//* w ww . j a v a 2s .co m*/ public static void main(String[] args) { try { // TODO code application logic here CloudantClient client = ClientBuilder.account("2efca010-d783-48ff-8b09-a85b380b66a3-bluemix") .username("2efca010-d783-48ff-8b09-a85b380b66a3-bluemix") .password("2f040ce083e86c585ae5638a7cdba89951097a8b8a9480544d9a3d18de955533").build(); // Show the server version System.out.println("NICOOL ES LOCA - Server Version: " + client.serverVersion()); // Get a List of all the databases this Cloudant account List<String> databases = client.getAllDbs(); System.out.println("All my databases : "); for (String db : databases) { System.out.println(db); } Database db = client.database("becario", false); InputStream is = db.find("650cb18385ff988b236611625fcc3a3e"); StringWriter writer = new StringWriter(); IOUtils.copy(is, writer, "UTF-8"); String theString = writer.toString(); System.out.println(theString); } catch (IOException ex) { Logger.getLogger(DemoCloudantClient.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:it.cnr.ilc.tokenizer.utils.InputToString.java
/** * Convert an inputstream into a string/*from w ww . jav a2 s . c o m*/ * @param is the inputstream * @return the string from the input */ public static String convertInputStreamToString(InputStream is) { StringWriter writer = new StringWriter(); String encoding = "UTF-8"; String message = ""; String theString = ""; try { IOUtils.copy(is, writer, encoding); theString = writer.toString(); } catch (Exception e) { message = "IOException in coverting the stream into a string " + e.getMessage(); Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, message); } //System.err.println("DDDD " + theString); IOUtils.closeQuietly(is); IOUtils.closeQuietly(writer); return theString; }
From source file:it.cnr.ilc.ilcioutils.IlcInputToString.java
/** * Convert an inputstream into a string//from w ww.j av a 2 s.c om * * @param is the inputstream * @return the string from the input */ public static String convertInputStreamToString(InputStream is) { StringWriter writer = new StringWriter(); String encoding = "UTF-8"; String message = ""; String theString = ""; try { IOUtils.copy(is, writer, encoding); theString = writer.toString(); } catch (Exception e) { message = "IOException in coverting the stream into a string " + e.getMessage(); Logger.getLogger(CLASS_NAME).log(Level.SEVERE, message); } //System.err.println("DDDD " + theString); IOUtils.closeQuietly(is); IOUtils.closeQuietly(writer); return theString; }
From source file:com.ontotext.s4.multiThreadRequest.utils.Util.java
public static String convertSreamToString(InputStream inputStream) throws IOException { StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, UTF_8_ENCODING); String theString = writer.toString(); return theString; }
From source file:net.fizzl.redditengine.data.FlairListing.java
public static FlairListing fromInputStream(InputStream is) throws IOException { StringWriter writer = new StringWriter(); IOUtils.copy(is, writer, "UTF-8"); return fromString(writer.toString()); }
From source file:net.fizzl.redditengine.data.ModlogListing.java
public static ModlogListing fromInputStream(InputStream is) throws IOException { StringWriter writer = new StringWriter(); IOUtils.copy(is, writer, "UTF-8"); return fromString(writer.toString()); }
From source file:net.fizzl.redditengine.data.MessageListing.java
public static MessageListing fromInputStream(InputStream is) throws IOException { StringWriter writer = new StringWriter(); IOUtils.copy(is, writer, "UTF-8"); return fromString(writer.toString()); }
From source file:com.mirth.connect.connectors.http.HttpUtil.java
public static String uncompressGzip(byte[] content, String charset) throws IOException { GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(content)); StringWriter writer = new StringWriter(); IOUtils.copy(gzis, writer, charset); return writer.toString(); }
From source file:com.cprassoc.solr.auth.util.Utils.java
public static String streamToString(InputStream in) { String result = ""; try {//w w w . j ava2 s . c om StringWriter writer = new StringWriter(); IOUtils.copy(in, writer, "UTF-8"); result = writer.toString(); } catch (Exception e) { //e.printStackTrace(); } return result; }
From source file:net.fizzl.redditengine.data.UserListing.java
public static UserListing fromInputStream(InputStream in) throws IOException { StringWriter writer = new StringWriter(); IOUtils.copy(in, writer, "UTF-8"); return fromInputStream(writer.toString()); }