File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create a byte array from a image file

 
ram ragu
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am totally new to java and I just wanted to know how to create a byte array from an image file i.e i have a test.gif on my local drive
(c:/test.gif)
It might be simple .. but i just started learning java.. but need to do this rightaway ..
let me know.
 
Jason Ford
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to create a byte array from a file, you just need to read in the file and store the result to an array:

If you really want a byte array instead of the char array, create a String with the char array and use the getBytes method on the String.
Unless I'm missing something...
HTH,
Jason
 
hennie louw
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



That might work but you can also try this

I'm just not sure if {array}.length value is the length of the array or the number of the last reffrence , but goo luck
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic