You need to obtain the file content first.
You might want to use a FileReader
for that.
new BufferedReader(new FileReader("path-to-file"));
Or if the file is in your classpath
final InputStream inputStream =
ClassLoader.getSystemClassLoader()
.getResourceAsStream("path-to-file");
new BufferedReader(new InputStreamReader(inputStream , "UTF-8"));
Then you can use the composed String
to construct a new JSONObject
.
To obtain an InputStream
for your File, which is an asset, you can leverate the AssetManager
. Pseudocode
InputStream is = AssetManager#open(fileName)