开发者

How to print the text file without boxes in java?

I have a text file that i'm trying to print but it prints开发者_如何学Go boxes in between two characters. My code works fine for all the text files except this particular one. I cannot copy-paste this box character. So that i can check if the given character is that box and not print it using if condition. Please help. Thanks


Without a sample of the text you are trying to print, I think that it might be an issue with encoding. Here is a list of encodings supported by the java language. You might then want to do something like this:

Charset charset = Charset.forName("US-ASCII");
String s = ...;
try (BufferedWriter writer = Files.newBufferedWriter(file, charset)) {
    writer.write(s, 0, s.length());
} catch (IOException x) {
    System.err.format("IOException: %s%n", x);
}

(Example taken from here.)


My guess is that your document is UTF-16 encoded. Try to reencode it to UTF-8 or ASCII.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜