Java tutorial
//package com.java2s; /* * Copyright (C) 2011-2013 Ulteo SAS * http://www.ulteo.com * Author Pierre Laine <plaine@ulteo.com> 2011 * Author Clment Bizeau <cbizeau@ulteo.com> 2011 * Author David PHAM-VAN <d.pham-van@ulteo.com> 2013 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { private static String readFully(InputStream inputStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int length = 0; while ((length = inputStream.read(buffer)) != -1) { baos.write(buffer, 0, length); } return new String(baos.toByteArray()); } }