从.csv文件中获取的字符编辑问题java
我有一个问题....
我制作了一个执行以下操作的java程序:
BufferedReader input = new BufferedReader(new FileReader("test.csv"));
String line = input.readLine();
int lenghtOfLine=line.length();
char[] lineIndex=new char[lenghtOfLine];
lineIndex=line.toCharArray();
现在我在for循环中进行一些检查,例如if(lineIndex[i]=='|')或'M' 和其他一些检查 以同样的方式...
问题是 allthought 程序在 windows 7、vista、xp(英语和希腊语)上运行正确 当我尝试运行它时 在 Windows Vista(德语)上,检查 lineIndex[i]=='|'
似乎始终为 false** 为什么会发生这种情况? test.csv 文件是相同的..并且我确信“|”每一行都存在..unicode
有问题还是什么?
我怎样才能让这个程序在每种语言中运行
test.csv 文件总是从网上下载的一些文件
我很抱歉我的英语。 提前致谢..
I have a problem....
I made a java program that does the following:
BufferedReader input = new BufferedReader(new FileReader("test.csv"));
String line = input.readLine();
int lenghtOfLine=line.length();
char[] lineIndex=new char[lenghtOfLine];
lineIndex=line.toCharArray();
Now i make some checks in a for loop such us if(lineIndex[i]=='|') or 'M'
and some other checks
in the same way...
The problem is that allthought the program run correct on windows 7, vista , xp (english and greek)
when i try to run it
on windows vista (German) it seems like the check lineIndex[i]=='|'
is always false**
why this happen? The test.csv file is the same.. and i am sure that '|' exists in every line..
Is there a problem with unicode or something??
how can i make this program run in every language
The test.csv file is always the some downloaded from the web
I am sorry for my English.
Thanks in advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
API 指定 FileReader 将假定它运行的机器的默认字符编码。
如果您知道 CSV 是 UTF-8 编码的,您可以尝试:
The API specifies that FileReader will assume that the default character encoding of the machine on which it runs.
If you knew the CSV was UTF-8 encoded you could try: