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);
精彩评论