Question

if I have a delimited text file with apostrophes in, like ' as in:

BB;Art’s Tavern;6487 Western Ave., Glen Arbor, MI 49636;

what do I need to do to allow those to be parsed correctly through a BufferedReader in Java? the code Im currently using to open the file for reading is thus in an android application:

StringBuffer buf = new StringBuffer();          
InputStream is = context.getResources().openRawResource(R.raw.lvpa);
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));

Currently the apostrophes are being returned as question marks ? in a black box. The contents of the file are then parsed into a model. any help would be appreciated:)

Thanks

Était-ce utile?

La solution

The file you are reading is not recorded in UTF-8. You need to know which encoding your file is in before you attempt to read it. If possible open it in whatever text editor you use to examine it and save it off in UTF-8 and try reading it again. (Some text editors will give the option of setting the encoding when you save the file.)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top