File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
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.


Ulf Dittmer
Marshal

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


Ping & DNS - my free Android networking tools app
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
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
 
Similar Threads
byte[] to BufferedImage
read and write file in parts
Junk data written into file when write() is used
Document Retrival from database.
Create a byte array from a image file