问题描述
帮我看看这段代码啊。publicStringreadImg2base64(StringimgPath){Stringstr="";Filef=newFile(imgPath);byte[]b=getBytesFromFile(f);sun.misc.BASE64Encoderencoder=newsun.misc.BASE64Encoder();str=encoder.encode(b);returnstr;}privatebyte[]getBytesFromFile(Filef){if(f==null){returnnull;}try{FileInputStreamstream=newFileInputStream(f);ByteArrayOutputStreamout=newByteArrayOutputStream(1000);byte[]b=newbyte[1000];intn;while((n=stream.read(b))!=-1)out.write(b,0,n);stream.close();out.close();returnout.toByteArray();}catch(IOExceptione){}returnnull;}BASE64码的返回值是readImg2base64函数的啊还是这个函数的getBytesFromFile的啊
时间: 2024-10-04 12:47:17