Here you can find the source of readTextFile(InputStream inStream)
public static String readTextFile(InputStream inStream)
//package com.java2s; /**// www . java 2s. com * Copyright (c) 2014 Far Eastone Telecommunications Co., Ltd. * All Rights Reserved. * * This software is the confidential and proprietary information of * Far Eastone Telecommunications Co., Ltd. ("Confidential Information"). * * You shall not disclose such Confidential Information and shall use it * only in accordance with the terms of license agreement you entered * into with Far Eastone Telecommunications Co., Ltd. */ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; public class Main { private static final String encoding = "UTF-8"; public static String readTextFile(InputStream inStream) { String content = ""; try { int ca = inStream.available(); byte[] by = new byte[ca]; inStream.read(by); content = new String(by, encoding); inStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return content; } }