-----很简单的问题,没分了也希望高手看一下-----

wangsucsdn 2004-11-21 02:51:37
public Vector GetFile(String TextFile) throws java.io.IOException
{
String record = new String();
Vector Str=new Vector();

int i = 0;
try {
RandomAccessFile rf3 = new RandomAccessFile(TextFile,"r");

while ((record = rf3.readLine()) != null) {
i ++;
if (i!=1) {
StringTokenizer test1 =new StringTokenizer(record,"\t");
//对每行数据剖分
String[] test_str=new String[7]; //数组初始化
int jj=0;
while (test1.hasMoreTokens())
{
test_str[jj]=test1.nextToken();
System.out.println(test_str[jj]);
jj++;
}


Str.addElement(test_str);
}
//System.out.println(record);
}

if (i==0)
{
Str.addElement("无内容!");
}
rf3.close();
// Str=comm.iso2utf(Str);
}
catch (Exception e) {
System.out.println("read file is error:"+e.getMessage());
}
return Str;
}
请问大家 在这个getfile方法中 我想对每行数据分析 如果非int型 我是不允许写入数据库的
请问在那里写异常 是用Integer.parseInt这个方法嘛?
谁给写个例子最好
...全文
84 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wssg 2004-11-21
  • 打赏
  • 举报
回复
try{
Integer.parseInt(..);//判断是否是int
//插入数据库...
}
catch(NumberFormatException e){
//不是int...
}
猫熊工作室 2004-11-21
  • 打赏
  • 举报
回复
我知道 Integer.parseInt 可是写在那阿?
haroyy 2004-11-21
  • 打赏
  • 举报
回复
Integer.parseInt就可以了
fmzbj 2004-11-21
  • 打赏
  • 举报
回复
帮你顶吧
猫熊工作室 2004-11-21
  • 打赏
  • 举报
回复
走过路过不要错过

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧