问题
I have a quite strange issue with Java, I'm getting an error on some machines only, I would like to know if there is any way I can avoid that:
This is the line of code concerned:
JSONTokener jsonTokener = new JSONTokener(
new InputStreamReader(is, "UTF-8"));
This is the error I get on some machines
The file *.java could not be compiled. Error raised is : The constructor JSONTokener(InputStreamReader) is undefined
回答1:
Check the classpath on the machines where this error occurs. This could happen because the library that contains the JSONTokener
class is from an older version, where only the JSONTokener(String)
is available, and not JSONTokener(Reader)
.
来源:https://stackoverflow.com/questions/3725541/java-the-constructor-jsontokenerinputstreamreader-is-undefined