The moose likes I/O and Streams and the fly likes Reading an Image from Local drive and store to ByteArray Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "Reading an Image from Local drive and store to ByteArray" Watch "Reading an Image from Local drive and store to ByteArray" New topic
Author

Reading an Image from Local drive and store to ByteArray

pavan aryan
Greenhorn

Joined: Feb 28, 2010
Posts: 15
I am working on a WebService that returns a Image from Server to Client. I followed different examples, and built a service that will reads a file from a URL and writes to a Byte Array.



Now i am looking for a way to read a file from local drive to ByteArray..i tried URL("c:\newimage.png") its not working..tried many ways from File to FileInputStream and BufferedInputStream to convert to bye array..nothing is working. Rest of code works only on ByteArray..i have to figure out a way to store an image from local directory to ByteArray....Please help Friends.

Thanks,
Kumar.


This message was edited 3 times. Last update was at by pavan aryan

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32421
Please read and follow ItDoesntWorkIsUseless and TellTheDetails.


Android appsImageJ pluginsJava web charts
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1169
If it's local, why URL ?

Check out File, InputStream and FileInputStream.


JDBCSupport - An easy to use, light-weight JDBC framework -
 
 
subject: Reading an Image from Local drive and store to ByteArray
 
developer file tools