在Java中读取UTF-8编码只会在某些地方产生问题

在Java中读取UTF-8编码只会在某些地方产生问题,utf-8,character-encoding,spring-batch,Utf 8,Character Encoding,Spring Batch,我正在Java Spring批处理中逐字节读取UTF_8编码的文件,并将内容保存在mongodb中。读取委托给FlatFileItemReader,编码作为UTF-8注入bean 我看到的是,只有在一个或两个特定的位置,umlaut字符在mongodb中存储时存在编码问题。我验证了原始文件中的内容是否正常。有趣的是,在其他地方,原始文件中的umlaut字符被正确解释并正确存储在mongodb中 你能帮忙吗 <bean id="recordReader" class="org.springf

我正在Java Spring批处理中逐字节读取UTF_8编码的文件,并将内容保存在mongodb中。读取委托给FlatFileItemReader,编码作为UTF-8注入bean

我看到的是,只有在一个或两个特定的位置,umlaut字符在mongodb中存储时存在编码问题。我验证了原始文件中的内容是否正常。有趣的是,在其他地方,原始文件中的umlaut字符被正确解释并正确存储在mongodb中

你能帮忙吗

<bean id="recordReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
    <property name="resource" value="file:#{jobExecutionContext['inputfile']}" />
    <property name="linesToSkip" value = "1" />
    <property name= "encoding" value ="UTF-8"/>
    <property name="lineMapper">
        <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper" >
            <property name = "lineTokenizer">
            <bean class = "com.xyz.NoQuoteDelimitedLineTokenizer">
                <property name = "strict" value = "false" />
                <property name = "names" value = "Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8" />
                    <property name="delimiter">
                        <util:constant static-field="org.springframework.batch.item.file.transform.DelimitedLineTokenizer.DELIMITER_TAB" />
                    </property>                     
            </bean>
            </property>
            <property name = "fieldSetMapper">
                <bean class = "com.xyz.MyFieldSetMapper" >      
                    <property name = "ctx" value="#{jobExecutionContext['contextBean']}"/>
                </bean>         
            </property>

        </bean>
    </property>
</bean>

请出示您的“MyFieldSetMapper”的代码@MichaelPralow:谢谢,Michael。我已经发布了MyFieldSetMapperCan,我们可以看到
LineTokenizer
的代码吗?
private void validateFields (String id, ConsumerDO ci, FieldSet fieldset_p) throws Exception 
{try {
        ci.setCaption(fieldset_p.readString("newCaption"));         
    }
    catch (Exception e) {

    }
}