星期一, 6月 27, 2011

[Java] Reading InputStream

如何使用Java 讀取InputStream資料。

//預設編碼為ANSI(ASCII)
  BufferedReader in = new BufferedReader(
          new InputStreamReader(inputStream));
  String currentLine = null;
  while((currentLine = in.readLine()) != null){
   System.out.println("currentLine" + currentLine);
  }

可指定編碼格式UTF-8
BufferedReader in = new BufferedReader(
new InputStreamReader(inputStream,"UTF-8"));

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails