Skip to content

Instantly share code, notes, and snippets.

@lichengwu
Created December 28, 2013 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lichengwu/8155504 to your computer and use it in GitHub Desktop.
Save lichengwu/8155504 to your computer and use it in GitHub Desktop.
最简单的方式把一个InputStream转换成String
/**
* 最简单的方式把一个InputStream转换成String
*
* @author lichengwu
* @version 1.0
* @created 2013-12-28 10:37 AM
*/
public class InputStreamAsString {
public static void main(String[] args) throws IOException {
InputStream inputStream = new URL("http://blog.lichengwu.cn/atom.xml").openStream();
String str = new Scanner(inputStream).useDelimiter("\\A").next();
System.out.println(str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment