I'm developing a Java Application using Netbeans, but while I run my app in Debug, or plain running it from Netbeans, my screen looks like so:
. Yet, when I try to run from the Built jar in the dist
folder, it looks like so: .
Here is the method in which I am using to receive the content. The method is intended to get the source of text file from the web.
public static ArrayList<String> getUrlSource(String urlF) throws IOException {
URL url = new URL(urlF);
Scanner s = new Scanner(url.openStream());
ArrayList<String> fileLines = new ArrayList<>();
while (s.hasNextLine())
{
fileLines.add(s.nextLine());
}
return fileLines;
}
答案 0 :(得分:2)
You're looking at the UTF-8 Byte Order Marker
The UTF-8 representation of the BOM is the byte sequence 0xEF,0xBB,0xBF. A text editor or web browser misinterpreting the text as ISO-8859-1 or CP1252 will display the characters  for this.
答案 1 :(得分:1)
The default charset may be different depending on how you launch the application. Try specifying the charset explicitly :
Scanner s = new Scanner(url.openStream(), "UTF-8");