File f = new File(path, fileName);
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);
//byteArray这是一个字节数组[],是图象转换而来的,现在就是要将这个转换过来的数组再转换回图象文件 fos.close();
InputStream in = new FileInputStream(f); FileSystemUtils.save(f,in);
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();
}//把这段执行完后生成一个图象文件,但是文件大小为零,
解决方案 »
- 各位过来人给个意见,SE部分看完了,是巩固呢,还是继续EE部分,回头再巩固SE?
- java标准输出重定向
- import和classpath的问题
- 我们该如何做界面?
- jsp实现文件批量下载问题,请高手赐教
- 奇怪,为什么 string 用 byte <<= 1 后,再 byte >>= 1,再 new String(b),得到的字符串为什么不是原来的 string ,怎么样才能得回原来
- How can I change the knob of the JSlider?
- 一个初学者的问题!
- Square is-a Rect? (more thoughts on immutable programming)
- Java实现单链表的操作,求大神解答!!!
- Server redirected too many times (20) 是什么错误?
- java新手,请问关于线程通信的问题。。。
f.delete();//delete it after using it
f.delete();//delete it after using it 这三句在这里有用吗?或是做其他的处理..如果单是保存byteArray的数据,不用上面三句就可以了......另外,图片用二进制流读写方便..