Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.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
Springboot java应用程序在遇到特殊字符(如美分符号)时拒绝数据加载过程_Java_Spring_Spring Boot - Fatal编程技术网

Springboot java应用程序在遇到特殊字符(如美分符号)时拒绝数据加载过程

Springboot java应用程序在遇到特殊字符(如美分符号)时拒绝数据加载过程,java,spring,spring-boot,Java,Spring,Spring Boot,在运行injestion进程时,当springboot/java遇到带有$,美分等字符的记录时,它将退出处理记录。代码使用java 8和springboot 2,并使用scanner对象逐行读取文件。在读取文件时,您可能需要正确定义编码 BufferedReader br = new BufferedReader(( new FileReader("/file.txt"),"ISO-8859-1")); line = br.readLine(); 注意:如果ISO-8859-1不起作用,您

在运行injestion进程时,当springboot/java遇到带有$,美分等字符的记录时,它将退出处理记录。代码使用java 8和springboot 2,并使用scanner对象逐行读取文件。

在读取文件时,您可能需要正确定义编码

BufferedReader br = new BufferedReader(( new FileReader("/file.txt"),"ISO-8859-1"));


line = br.readLine();

注意:如果ISO-8859-1不起作用,您可以将其替换为UTF-8

您可以与我们分享您的代码吗。这对我来说毫无意义,因为他已经更新了。现在它更有意义了。while(scanner.hasNextLine()){dataScanner=scanner.nextLine();//用于读取文件的scanner对象,我已经用UTF-8测试过了,没有,但仍然是一样的。