Re: Taking the Contents of a File object and converting it to a byte array
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 20:21:51 +0000
Roedy Green wrote:
On 30 Dec 2005 08:33:14 -0800, "MattC" <matthew.n.connors@xxxxxxxx> wrote, quoted or indirectly quoted someone who said :
/* Move the data in the File object to a byte array */ InputStream in = new FileInputStream(templateFile); int length = new Long(templateFile.length()).intValue();
(I didn't see that...)
You don't need a ByteArrayOutputStream or a byte[1024] buffer.
Even if you did need a buffer, use a BufferedInputStream rather than rolling your own.
You don't mean reading a byte at a time, do you? If nothing else, the synchronisation would kill performance, unless the JVM was something special.
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- References:
- Prev by Date: generic oversight?
- Next by Date: Re: ajax server design question
- Previous by thread: Re: Taking the Contents of a File object and converting it to a byte array
- Next by thread: Install keystroke on action without using a JMenuItem
- Index(es):
Relevant Pages
|