参数为读取的文件名,中文为双字节,我想substring里面的参数应该为2,没有测试,也可能为1。a即为title,b即为content public void filtrate(File news)
{
try
{ BufferedReader tfile=new BufferedReader(new FileReader(news));
String addressLine="";
String title="";
String content="";
while ((addressLine=tfile.readLine())!=null)
{
title=addressLine.substring(0,2); //可能为1
content=addressLine.substring(2); //可能为1
}
tfile.close();
}
catch(FileNotFoundException excpt)
{ writeLog("Unable to find file:"+excpt);
}
catch(IOException excpt)
{ writeLog("Failed I/O of file:"+excpt);
}
}
{
try
{ BufferedReader tfile=new BufferedReader(new FileReader(news));
String addressLine="";
String title="";
String content="";
while ((addressLine=tfile.readLine())!=null)
{
title=addressLine.substring(0,2); //可能为1
content=addressLine.substring(2); //可能为1
}
tfile.close();
}
catch(FileNotFoundException excpt)
{ writeLog("Unable to find file:"+excpt);
}
catch(IOException excpt)
{ writeLog("Failed I/O of file:"+excpt);
}
}
解决方案 »
- 关于Java转换pdf文件的相关知识
- Hibernate问题 时好时坏 解决不了啦
- jsp中out.print与<%=%>的困扰
- 真正高手请进,一个关于JTable的问题………………!!
- 请问一下ant 能不能读取一个文本文件然后把文件里的内容显示出来?
- jacob 打开excel问题
- "0xC0C0BABE" 有什么特殊的含义吗?
- 太莫名其妙!!!我是这样被逼疯的:很简单的东西,但是找不到错误根源???也许是我太菜了???看高人们的法眼如何??
- 今天去面试的一道题请高手指点
- java多个文件连续读取效率如何提高?
- 初学java,简单问题,顺便请推荐java学习电子书!希望交流。
- JAVA参考书??介绍几本!!
while (fin.readLine() != null) {
//每读一行就处理
}