String str = "abc";
byte[] b = str.getBytes();
for (int i = 0, size = b.length; i < size; i++)
System.out.println((char)b[i]);
byte[] a = new byte[2];
a[0] = (byte)0xb0;
a[1] = (byte)0xa1;
String str = new String(a);
//******************************************************Oracle blol 類型轉換
blob字段
java中用 byte[]
xx.hbm.xml中 用 <property name="xx" type="binary" lazy="true">
配置文件寫成java.sql.Blob類型
程序裏這寫:
worker.setPhoto(Hibernate.createBlob(new byte[1]));
SerializableBlob sb = (SerializableBlob ) worker.getPhoto();
java.sql.Blob wrapblob = sb.getWrappedBlob();
oracle.sql.BLOB blob = (oracle.sql.BLOB) wrapblob;
OutputStream out = blob.getBinaryOutputStream();
byte [] buf=new byte[(int)in.available()];
這樣就轉成了字節數組了
http://blog.csdn.net/winer2008/archive/2009/07/26/4381122.aspx