I have a problem. I am using a file to load some strings to use them in my App.
I have this function:
public void lecturaFichero(){
String linea = null;
try {
InputStream in = cntx.getAssets().open("cc.txt");
if (in != null) {
InputStreamReader input = new InputStreamReader(in,Charset.forName("iso-8859-1"));
BufferedReader buffreader = new BufferedReader(input);
while ((linea = buffreader.readLine()) != null) {
rellenaCodigo(linea);
}
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
The problem is that when I run the app it crashes right away (reading the file is the first thing I do).
If I do this instead of the above:
InputStreamReader input = new InputStreamReader(in)); //Without specifying the charset
It does work, it does not crash but the app shows where that special characters should be.
I need to solve this, I'd appreciate a solution in which I can read special characters in my app.
Thanks in advance.
PS: Android can print special characters because when I type a String by hand and print it on the screen it shows the character, the problem is when it comes to reading from the .txt.