首页 > 编程知识 正文

object转string,int转为string

时间:2023-05-06 15:55:52 阅读:133390 作者:4224

1.InputStream到String /* *InputStream的字符串*/publicstringinputstrtostr (inputstream inputstream ) throwsioexception { byttrem //将文件内容读取到字节数组int offset=0中int numRead=0; while (offset bytes.length (numread=inputstream.read ) bytes,offset,bytes.length - offset ) )0) offset=nuf stream } inputStream.close (; stringencodedfilestring=base64.get encoder ().encodetostring(bytes ); 返回编码文件字符串; }2.从string转换为InputStream /* *字符串inputstream */publicinputstreamstr2inputstr (string instr (try ) byte ) bytes=base66s }catch(exceptione ) {e.printStackTrace ); }返回空值; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。