我的代码里
byte[] filecontent = decoder.decodeBuffer(body);解码出一个byte[],这个是个文件类型,我想转化回去File应该怎么做啊File testFile = new File(filecontent....);诸如此类的 谢谢
byte[] filecontent = decoder.decodeBuffer(body);解码出一个byte[],这个是个文件类型,我想转化回去File应该怎么做啊File testFile = new File(filecontent....);诸如此类的 谢谢
out.write(filecontent);[
FileInputStream input=new FileInputStream(testFile);
byte[]buffer=new byte[65560];
int bytes;
bytes=input.read(buffer,0,65560);
FileOutputStream output=new FileOutputStream("d:\\filecontent.txt")
output.write(buffer,0,bytes);
自己试试!!!
不过你可以类似下面这样先建一个,然后把你的bytes写进去,用完后再删掉byte[] byteArray={0x59,0x34,0x45};
File f = new File("temp.te");
if(!f.exists())
{
try {
f.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
FileOutputStream fos;
try {
fos = new FileOutputStream(f);
fos.write(byteArray);
fos.close();
//do something you want;
f.delete();//delete it after using it
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
经过你怎么做
我再这个位置增加了
InputStream in = new FileInputStream(f); FileSystemUtils.save(f,in);但是保存进去的是一个空文件,图象的字节为零这是什么问题
我再你代码这个位置增加了
InputStream in = new FileInputStream(f); FileSystemUtils.save(f,in); 但是图象保存进去的是一个空文件,图象的字节为零 这是什么问题
FileOutputStream fos = new FileOutputStream("文件路径");
fos.write(/*你的字节数组*/);
你可以创建一个File的虚拟文件 然后传给它 再creatFile,
试试可以不.我也接触不久,就是提供一个想法