![](/img/trans.png)
[英]Should I close the InputStream of org.apache.commons.io.IOUtils
[英]Why there is still error after i import the org.apache.commons.io.IOUtils? How to resolve them and how to add the import properly?
import java.util.Scanner;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.json.JSONException;
import org.json.JSONObject;
public class Activity {
public static void main1(String[] args) {
try {
InputStream is = ReadJsonClass.class.getResourceAsStream(myData.json );
String text = IOUtils.toString(is, "UTF-8") ;
JSONObject myJsonObject = new JSONObject(text);
System.out.println(myJsonObject);
} catch (IOException | JSONException e) {
System.out.println("Try you have never caught before");
}
}
myData.json 必须用双引号引起来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.