1

我正在使用java读取文件。文件包含 € 字符,但 java 将其解释为¿.

即文件内容“ 12rl+€/h”从java读取“ 12rl+¿/h

更新:我正在使用骆驼文件组件阅读它:

<camel:route id="FileProcessor">
  <camel:from uri="file:c://my/temp/" />
  <camel:log message="File ${body}" loggingLevel="DEBUG" logName="CamelLogger"/>
  <camel:process ref="fileProcessor"/>
  <camel:log message="File has been processed" loggingLevel="DEBUG" logName="CamelLogger"/>
</camel:route>

public class FileProcessor implements Processor {
    private static final Logger logger = LoggerFactory.getLogger(FileProcessor.class);

    public FileProcessor() {
    }

    @Override
    public void process(Exchange exchange) throws Exception {
        String fileContent = exchange.getIn().getBody(String.class);
        //Buisness logic with file
    }

如何解决这个问题

4

1 回答 1

3

我从未使用过 Camel,但 Google 将我带到了这个文档页面,它解释了可以在 URL 中添加一个选项来指定字符集:

file:c://my/temp/?charset=UTF-8
于 2012-07-16T10:43:50.960 回答