关键的代码和正则表达式在这里

 

while((line=br.readLine())!=null)
			{
				String[] data=new String[4];
				data=line.split("\\s{1,}");
				
				String sql="insert into cat_keyword values('"+data[0]+"','"+data[1]+"','"+data[2]+"','"+data[3]+"')";
				stmt.executeUpdate(sql);				
			}
		}


如果用简单的“ ”做分隔符,那么就无法处理有好多空格的情况,数据和表格字段根本对不上,也就无法正确入库了,所以这段小代码还是很有用处的。

 

 

相关文章:

  • 2021-05-16
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2021-12-25
  • 2021-12-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
相关资源
相似解决方案