<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Read a file into a byte array</title>
	<atom:link href="http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/</link>
	<description>Simple yet powerful Java programming</description>
	<lastBuildDate>Wed, 08 Feb 2012 15:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Paul</title>
		<link>http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/comment-page-1/#comment-13597</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Tue, 10 May 2011 16:16:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=16#comment-13597</guid>
		<description>The loop should be enclosed in a try/finally. ie:

try { readloop } finally { is.close() } otherwise you will leave streams open if there is an error.

Also, for efficiency, you would normally want to wrap your FileInputStream with a BufferedInputStream.
use a</description>
		<content:encoded><![CDATA[<p>The loop should be enclosed in a try/finally. ie:</p>
<p>try { readloop } finally { is.close() } otherwise you will leave streams open if there is an error.</p>
<p>Also, for efficiency, you would normally want to wrap your FileInputStream with a BufferedInputStream.<br />
use a</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ricardoz</title>
		<link>http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/comment-page-1/#comment-11364</link>
		<dc:creator>ricardoz</dc:creator>
		<pubDate>Fri, 25 Mar 2011 13:12:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=16#comment-11364</guid>
		<description>@Jake: from the FileInputStream javadoc

&quot;Returns: the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached.&quot;

The problem you mention shouldn&#039;t happen since after EOF is found read should always return -1.</description>
		<content:encoded><![CDATA[<p>@Jake: from the FileInputStream javadoc</p>
<p>&#8220;Returns: the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached.&#8221;</p>
<p>The problem you mention shouldn&#8217;t happen since after EOF is found read should always return -1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jake</title>
		<link>http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/comment-page-1/#comment-11337</link>
		<dc:creator>Jake</dc:creator>
		<pubDate>Fri, 25 Mar 2011 00:32:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=16#comment-11337</guid>
		<description>What about the potential infinite loop if the stream encounters an EOF in the middle of the file and then numRead will continue to be set to 0 and hence will never increase the offset.  and then we&#039;ll cycle and cycle.</description>
		<content:encoded><![CDATA[<p>What about the potential infinite loop if the stream encounters an EOF in the middle of the file and then numRead will continue to be set to 0 and hence will never increase the offset.  and then we&#8217;ll cycle and cycle.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shaun Hol</title>
		<link>http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/comment-page-1/#comment-9074</link>
		<dc:creator>Shaun Hol</dc:creator>
		<pubDate>Wed, 26 Jan 2011 15:45:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=16#comment-9074</guid>
		<description>Sorry ignore that - The second param is the offset into the array, not the offset into the file itself.</description>
		<content:encoded><![CDATA[<p>Sorry ignore that &#8211; The second param is the offset into the array, not the offset into the file itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shaun Hol</title>
		<link>http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/comment-page-1/#comment-9072</link>
		<dc:creator>Shaun Hol</dc:creator>
		<pubDate>Wed, 26 Jan 2011 14:21:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=16#comment-9072</guid>
		<description>Is there a bug here, or did I miss something ?
The bytes buffer address isn&#039;t getting updated during iteratons of the loop.</description>
		<content:encoded><![CDATA[<p>Is there a bug here, or did I miss something ?<br />
The bytes buffer address isn&#8217;t getting updated during iteratons of the loop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ricardoz</title>
		<link>http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/comment-page-1/#comment-57</link>
		<dc:creator>ricardoz</dc:creator>
		<pubDate>Fri, 24 Oct 2008 17:43:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=16#comment-57</guid>
		<description>@stronghead: The code reads any file as binary content, so it really doesn&#039;t mind what&#039;s inside of it. You probably have a problem somewhere else, post your code if you want.</description>
		<content:encoded><![CDATA[<p>@stronghead: The code reads any file as binary content, so it really doesn&#8217;t mind what&#8217;s inside of it. You probably have a problem somewhere else, post your code if you want.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stronghead</title>
		<link>http://www.spartanjava.com/2008/read-a-file-into-a-byte-array/comment-page-1/#comment-55</link>
		<dc:creator>Stronghead</dc:creator>
		<pubDate>Wed, 22 Oct 2008 06:54:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.spartanjava.com/?p=16#comment-55</guid>
		<description>But this code cannot read the doc file which has table in it.. Any help??</description>
		<content:encoded><![CDATA[<p>But this code cannot read the doc file which has table in it.. Any help??</p>
]]></content:encoded>
	</item>
</channel>
</rss>

