开发者

How to read line by line with android using eclipse

开发者 https://www.devze.com 2023-04-05 18:17 出处:网络
I have been doing a project where I want to read a text file line by line. I have try to use the next line of code:

I have been doing a project where I want to read a text file line by line. I have try to use the next line of code:

my text file name and location: src/raw/cordenadas.txt

import java.io.InputStream;
impo开发者_Go百科rt java.io.InputStreamReader;
import java.io.BufferedReader;

InputStream is = getResources().openRawResource(R.raw.cordenadas);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader (is, "UTF-8"));

But I receive the error unhandled exception UnsupportedEncodingException in the second line of code

Can some one please help me, and also what imports Java I have been mising? If you can help me by improving this line of code or by providing a new code it won't matter


Encoding should be "UTF8". See Supported Encodings.


Try This::

String encoding = "utf8";
int SIZE = 8192;
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), encoding),SIZE);
0

精彩评论

暂无评论...
验证码 换一张
取 消