Answer the question
In order to leave comments, you need to log in
How to read a file into a Java array?
There is a file in the asset folder. How to read it into a string array? Here is my code, how to specify path to asset folder?
ArrayList<String> list = new ArrayList<>();
try (Scanner scan = new Scanner(new File("slova.txt"))) {
while (scan.hasNextLine()) {
list.add(scan.nextLine());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
You need to use AssetManager. You can get it using the Context::getAssets method. The manager has an open method, where you can pass the path relative to the assets park.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question