How to convert the DataInputStream to the String in Java?

后端 未结 3 1235
旧巷少年郎
旧巷少年郎 2020-12-19 00:14

I want to ask a question about Java. I have use the URLConnection in Java to retrieve the DataInputStream. and I want to convert the DataInputStream into a String variable i

3条回答
  •  情书的邮戳
    2020-12-19 00:47

    You can use commons-io IOUtils.toString(dataConnection.getInputStream(), encoding) in order to achieve your goal.

    DataInputStream is not used for what you want - i.e. you want to read the content of a website as String.

提交回复
热议问题