Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 列表<;字符串>;具有要编码为UTF-8的实体_Java_Utf 8 - Fatal编程技术网

Java 列表<;字符串>;具有要编码为UTF-8的实体

Java 列表<;字符串>;具有要编码为UTF-8的实体,java,utf-8,Java,Utf 8,我有一个获取regex值并添加到列表中的列表 private static List<String> listaOfQuestion(Scanner sc, List<File> listaQuestion) { List<String> question = new ArrayList<String>(); for (File input1 : listaQuestion) { try {

我有一个获取regex值并添加到列表中的列表

private static List<String> listaOfQuestion(Scanner sc, List<File> listaQuestion) {
    List<String> question = new ArrayList<String>();
    for (File input1 : listaQuestion) {
        try {
            sc = new Scanner(input1);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        while (sc.hasNextLine()) {
            Scanner s = new Scanner(sc.nextLine());
            while (s.hasNext()) {
                String words = s.nextLine();
                try {
                    question.add(getTagValuesQ(words).toString());
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

    return question;
}

我尝试使用Apache Common Lang并解决了这个问题:

    String s = "Biela&#x144;ska Wyzi&#x144;ski Wci&#x15B;lik";
    String decoded = org.apache.commons.lang3.StringEscapeUtils.unescapeHtml4(s);
    System.out.println(decoded);        
输出:

Bielańska Wyziński Wciślik

您想在哪里进行编码?我看不到在您的代码中使用它的任何示例。还有另一个Scanner构造函数:
公共Scanner(文件源,字符串charsetName)
,您可以在其中指定一个字符集。@Berger,这将是解码,但这是对OP含义的最佳猜测+1担心我的同事来拜访我,我编辑了我的问题真的很抱歉。Berger我使用这样的扫描器进行(File input1:listaQuestion){try{sc=new Scanner(input1,“UTF-8”);}catch(FileNotFoundException e){e.printStackTrace();}但它不起作用。我相信你的解决方案是好的,但我认为我试图以错误的方式来做这件事。
Bielańska Wyziński Wciślik