java - 构建时显示奇怪的字符,但不显示调试

标签 java string url web

我正在使用 Netbeans 开发 Java 应用程序,但是当我在 Debug 中运行我的应用程序时,或者从 Netbeans 直接运行它时,我的屏幕如下所示: Good .然而,当我尝试从 dist 文件夹中的 Built jar 运行时,它看起来像这样:Bad .

这是我用来接收内容的方法。该方法旨在从网络上获取文本文件的来源。

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;
}

最佳答案

您正在查看 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.

关于java - 构建时显示奇怪的字符,但不显示调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33445439/

相关文章:

java - MS Word 识别标题/字体等?

java - 无法使用 DateTime 作为名称创建文件夹

c# - 如何重复一组字符

c - 将三个动态 Char** 数组添加到一个静态数组。 (C)

sql-server-2008 - SQL Server 2008-存储和搜索URL(网址)

ios - 使用谷歌网址缩短器进行重定向的通用链接

url - 如何使 "URL Protocol"从其自己的目录启动应用程序而不是从 c :\windows\system32? 启动

java - MongoDB 和 Spring Boot - 更新文档的最佳方式?

java - 围绕正方形平移

php - 将 TINYINT(1) 转换为字符串