vendredi 27 février 2015

String methods not working b/w utf-8 string and a java string

I am reading a file from android device using BufferedReader(new InputStreamReader(fis, "UTF-8")); and building a string using string builder. Resulting string has blank characters before every character. Thus string methods such as replace, indexof not working when used with java string. Code: String FILENAME = "sedata_file"; FileInputStream fis = null; BufferedReader d;



try {
fis = openFileInput(FILENAME);
d = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
String st;
StringBuilder sb = new StringBuilder();
do {
st = d.readLine();
if (st != null) { sb.append(st); sb.append('\n'); }
} while (st != null);
completest = sb.toString();
completest.replaceAll("zap" , "nap");


Appreciate it, had lost lots of hours to this.


Aucun commentaire:

Enregistrer un commentaire