*******如何用java读取sql server的binary类型的字段? 急急,在线等 sql server的表中有一个字段是binary类型的,向里存的是字符串,在java程序中如何将其读出来并转换成中文字符串,并且能正常显示出来?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ResultSet rs;String s=new String(rs.getBinaryStream(int i).getBytes("ISO8859_1"), "GBK"); i为select结果的第i列 使用java中的byte[]类型,get方法是byte[] getBytes[] ResultSet rs=pstmt.executeQuery();rs.next();String s=new String(rs.getBytes("字段名")); InputStream in = rs.getBinaryStream("字段名"); String strFile = "c:\\1.jpg";//假设是一个画像 OutputStream out = new FileOutputStream(strFile); byte[] bytes = new byte[1024]; while(in.read(bytes,0,1024) != -1){ out.write(bytes); } out.close(); in.close(); ft,看错题目了.InputStream in = rs.getBinaryStream("字段名");BufferedReader in = new BufferedReader(new InputStreamReader(in));String s="";int nLine =0;String strResult = "";while((s=in.readLine())!=null){ strResult = strResult +s;} MyEclipse的问题 关于red5服务端配置的问题 关于序列化的问题 JAVA自测题栏目里的一道难解的题目 日文项目,中文系统下JBuilder开发,翻译成日文,出现问题!急寻帮助!寻求相同项目经历! 请问如何读tomcat中启动信息 关于线程java.lang.Runnable的问题100分 我的第一个JAVA程序(hello world)就有问题,郁闷! 运行错误!这是我的第一个java 程序! 小白算法请教 如何用java读取sql server的binary类型的字段? 急急,在线等 Swing问题!
String s=new String(rs.getBinaryStream(int i).getBytes("ISO8859_1"), "GBK");
i为select结果的第i列
rs.next();
String s=new String(rs.getBytes("字段名"));
String strFile = "c:\\1.jpg";//假设是一个画像
OutputStream out = new FileOutputStream(strFile);
byte[] bytes = new byte[1024];
while(in.read(bytes,0,1024) != -1){
out.write(bytes);
}
out.close();
in.close();
BufferedReader in = new BufferedReader(new InputStreamReader(in));
String s="";
int nLine =0;
String strResult = "";
while((s=in.readLine())!=null){
strResult = strResult +s;
}