How to replace InputStream with BufferedReader

Asked 2 years ago, Updated 2 years ago, 134 views

I wrote InputStream to read text line by line from Android Asset Folder. If I use Buffered Reader, I can use readLine(), so I want to change InputStream to Buffered Reader What should I do?

InputStream is;
is = myContext.getAssets().open ("file.txt");
BufferedReader br = new BufferedReader (is);

Here, on the third line

Multiple markers at this line
The constructor BufferedReader (InputStream) is undefinded.

I get this error.

As in C

StreamReader file;
file = File.OpenText ("file.txt");

line = file.ReadLine();
line = file.ReadLine();
...

I want to do it this way, but did I do something wrong? What should I do?

android java inputstream readline bufferedreader

2022-09-21 16:24

1 Answers

BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));

BufferedReader cannot convert InputStream directly. So you have to do it like above.


2022-09-21 16:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.