Java tutorial
//package com.java2s; //License from project: Apache License import java.io.InputStream; import java.io.StringReader; import java.util.Scanner; public class Main { private static StringReader fromStreamToStringReader(InputStream inputStream, String encoding) { StringBuilder content = new StringBuilder(); Scanner scanner = null; try { scanner = new Scanner(inputStream, encoding); while (scanner.hasNextLine()) { content.append(scanner.nextLine()).append("\n"); } } finally { if (scanner != null) { scanner.close(); } } return new StringReader(content.toString()); } }