The file appears to be encoded in UTF-8. You should read it as UTF-8.
If you use java.io.FileReader and company, you should open FileInputStream and use InputStreamReader instead:
// Before: Reader in = new FileReader(file) Reader in = new InputStreamReader(new FileInputStream(file), "UTF-8");
If you use any other method to read the file (perhaps for an external or internal class library?), Check its documentation if it allows you to specify the text encoding used to read the file.
Update: If you already have String mojibake, for example £97.55 , and it cannot fix the reading method, one way to transcode is to convert the string to bytes and re-interpret the bytes as UTF-8. This process does not require any external "StringUtils" or codec library; The standard Java API is quite powerful:
String input = ...obtain from somewhere...; String output = new String(input.getBytes(), "UTF-8");
Joni
source share