• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

write byte[] to file?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you write byte[] to a File of an image type.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you've already got the byte[], then just



would do it (import java.io.FileOutputStream, of course.)
 
Subha Rangu
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I could write the byte[] to a file.But I want to have that with a particular extension. Like "tif". the code I wrote:

File f=new File("c:/temp/od/test.tif");
FileOutputStream fout = new FileOutputStream(f);
fout.write(b);//b is byte[] obtained..
fout.close();
return f;

My question is:
Is this the right way to specify the file extension?. I could open the file from ie,paint etc. But the problem is I was not able to include it in <img> tag using HTML. I appreaciate if someone could help me out.
Thanks
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The img tag doesn't support TIF. The only reason IE opens the file is because Windows associates the TIF file extension with Kodak Imaging for Windows program. Use a PNG, JPG or GIF if you want to embed the image in HTML.
 
reply
    Bookmark Topic Watch Topic
  • New Topic