我从前台传入的数据是string类型的,数据库对应的类型是byte类型,怎么转换这2种类型?

解决方案 »

  1.   

    string->byte  
    Byte static byte parseByte(String s)  
       
     byte->string  
     Byte static String toString(byte b)  
       
      

  2.   

    String   s   =   "abc "; 
    byte[]     bs   =   s.getBytes(); 
      

  3.   

    String s = "abc ";  
    byte[] bs = s.getBytes("UTF-8");
      

  4.   

    byte->String:new(Byte.value(byte b)).toString()
    String->byte:new(Byte.valueOf(String s)).byteValue()
      

  5.   

    String 好像本身就有现成的方法。
      

  6.   

    Stirng 变为byte类型有很多种编码格式,楼主可以根据自己的需求从新定义自己所需要的编码..