【java】arcII码为0x01,0x02作为分隔符

不知道大家在拼接字符串的时候是怎么做的?是不是采用,或:? 
这样做有的时候不很安全,因为你不能确保你传入的字符串中没有这几个字符,那怎么做能保证万无一失呢? 

arcII码为0x01,0x02的字符是键盘所不能输入的,因为用这个能保证万无一失。 

public String GetEnterpriseInfo(String code) {
		
		Connection cn = null;
		PreparedStatement stm = null;
		ResultSet rs = null;
		String s = "";
		byte  b1[] = {0x02};
		byte  b2[] = {0x01};
		String str1 = new String(b1); 
		String str2 = new String(b2); 
		try {
			cn = DBUtil.getConn();
			String sql = "select station_id,station_desc from  t_cfg_station_info where area_id like '%"+code+"%'";
			stm = cn.prepareStatement(sql);
			rs = stm.executeQuery();
			while(rs.next()){
				s += rs.getString(1)+str1+rs.getString(2)+str2;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			DBUtil.close(rs, stm, cn);
		}
		return s;
	}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值