请教如何解决写入的文件无法打开的问题,程序如下 ( 积分: 100 )

  • 主题发起人 旋转的影子
  • 开始时间

旋转的影子

Unregistered / Unconfirmed
GUEST, unregistred user!
//读取文件
FileInputStream dataFOS = new FileInputStream("V://a.jpg");
byte[] dd = new byte[1024];
StringBuffer strbuffer = new StringBuffer();
while(dataFOS.read(dd, 0, 1024)!=-1)
{
strbuffer.append(new String(dd));
dd = new byte[1024];
}
dataFOS.close();
//写入文件
File file=new File("V://m.jpg");
if(!file.exists())
file.createNewFile();
FileOutputStream out=new FileOutputStream(file);
out.write(buffer);
out.close();
 
追加到未尾试试
 
好像是没有加上文件结束符,在读完以后在末尾加个文件结束符试试!!
 
顶部