<?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: How to read properties file in Java.</title>
	<atom:link href="http://www.zparacha.com/how-to-read-properties-file-in-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zparacha.com/how-to-read-properties-file-in-java/</link>
	<description>Effective programming and blogging tips by Zaheer Paracha</description>
	<lastBuildDate>Sat, 11 Feb 2012 03:00:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Jakobi Freeman</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-1803</link>
		<dc:creator>Jakobi Freeman</dc:creator>
		<pubDate>Wed, 30 Nov 2011 18:47:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-1803</guid>
		<description>Nice, but how do you read integer values? Or doubles, floats, etc... Can it only read string values?</description>
		<content:encoded><![CDATA[<p>Nice, but how do you read integer values? Or doubles, floats, etc&#8230; Can it only read string values?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yem</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-1781</link>
		<dc:creator>yem</dc:creator>
		<pubDate>Fri, 25 Nov 2011 11:16:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-1781</guid>
		<description>thanks friend</description>
		<content:encoded><![CDATA[<p>thanks friend</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: armejaap</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-1744</link>
		<dc:creator>armejaap</dc:creator>
		<pubDate>Thu, 10 Nov 2011 13:55:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-1744</guid>
		<description>@Rashim

I think you have to escape &quot;:&quot; and &quot;=&quot;. So the new line in your properties file would be:
targetUrl=https\://foobar:9080/foo
Hope this helps.</description>
		<content:encoded><![CDATA[<p>@Rashim</p>
<p>I think you have to escape &#8220;:&#8221; and &#8220;=&#8221;. So the new line in your properties file would be:<br />
targetUrl=https\://foobar:9080/foo<br />
Hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Priya</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-1710</link>
		<dc:creator>Priya</dc:creator>
		<pubDate>Sat, 15 Oct 2011 06:42:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-1710</guid>
		<description>Cna we read from properties file without using InputStream. I mean I want asingle line access to key in properties file through my swings program.</description>
		<content:encoded><![CDATA[<p>Cna we read from properties file without using InputStream. I mean I want asingle line access to key in properties file through my swings program.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saia</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-1240</link>
		<dc:creator>saia</dc:creator>
		<pubDate>Fri, 24 Dec 2010 05:57:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-1240</guid>
		<description>Hai 
 provide more examples</description>
		<content:encoded><![CDATA[<p>Hai<br />
 provide more examples</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SANDHYARAJ</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-1239</link>
		<dc:creator>SANDHYARAJ</dc:creator>
		<pubDate>Fri, 24 Dec 2010 05:56:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-1239</guid>
		<description>Hai Friends,

i need more clarification regarding the properties file and how to retrive the values from the properties to a java file.
 and provide more examples</description>
		<content:encoded><![CDATA[<p>Hai Friends,</p>
<p>i need more clarification regarding the properties file and how to retrive the values from the properties to a java file.<br />
 and provide more examples</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shashi kanth</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-1229</link>
		<dc:creator>shashi kanth</dc:creator>
		<pubDate>Mon, 06 Dec 2010 09:23:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-1229</guid>
		<description>Hi Zaheer,
it&#039;s excellent one. i was trying with file input stream as shown below, but application unable to catch the file. getting file not found exception, after replacing these with your above eg. now it is working fine. thank you very much.
and may i know the fault in my below code, y i am getting errror ??

	File propsFile = new File(filePath);
	FileInputStream fileInputStream = new FileInputStream(propsFile);		
	prop.load(new FileInputStream(&quot;db.properties&quot;));
        System.out.println(&quot;Driver Name : &quot;+prop.getProperty(&quot;driverName&quot;));</description>
		<content:encoded><![CDATA[<p>Hi Zaheer,<br />
it&#8217;s excellent one. i was trying with file input stream as shown below, but application unable to catch the file. getting file not found exception, after replacing these with your above eg. now it is working fine. thank you very much.<br />
and may i know the fault in my below code, y i am getting errror ??</p>
<p>	File propsFile = new File(filePath);<br />
	FileInputStream fileInputStream = new FileInputStream(propsFile);<br />
	prop.load(new FileInputStream(&#8220;db.properties&#8221;));<br />
        System.out.println(&#8220;Driver Name : &#8220;+prop.getProperty(&#8220;driverName&#8221;));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zaheer</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-454</link>
		<dc:creator>Zaheer</dc:creator>
		<pubDate>Thu, 09 Jul 2009 15:27:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-454</guid>
		<description>Rashmi, you don&#039;t have to do anything special to read the URL from properties file. Follow the example I provided and you should be able to read the URL from the file. If you can share your code I&#039;ll be glad to help you with malformed exception.
To read an integer value you read the value from the file as String and then convert that value to an int using valueOf method of the Integer class. In my example I read numberOfFiles from the file, here is how you can convert that to an int.
               String numberOfFiles = prop.getProperty(&quot;NumberOfFiles&quot;);
	  	 int number = Integer.valueOf(numberOfFiles);

Hope this helps, otherwise feel free to &lt;a href=&quot;http://www.zparacha.com/contact-us/&quot;&gt;contact&lt;/a&gt; me directly.</description>
		<content:encoded><![CDATA[<p>Rashmi, you don&#8217;t have to do anything special to read the URL from properties file. Follow the example I provided and you should be able to read the URL from the file. If you can share your code I&#8217;ll be glad to help you with malformed exception.<br />
To read an integer value you read the value from the file as String and then convert that value to an int using valueOf method of the Integer class. In my example I read numberOfFiles from the file, here is how you can convert that to an int.<br />
               String numberOfFiles = prop.getProperty(&#8220;NumberOfFiles&#8221;);<br />
	  	 int number = Integer.valueOf(numberOfFiles);</p>
<p>Hope this helps, otherwise feel free to <a href="http://www.zparacha.com/contact-us/">contact</a> me directly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rashmi</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-448</link>
		<dc:creator>Rashmi</dc:creator>
		<pubDate>Wed, 08 Jul 2009 20:34:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-448</guid>
		<description>Is there a different format for reading URL values from the properties file? 

My property file has 

targetUrl=https://foobar:9080/foo

I am getting a malformed exception error. Do you think I am missing something?

Also, how do we read integer values from the properties file?</description>
		<content:encoded><![CDATA[<p>Is there a different format for reading URL values from the properties file? </p>
<p>My property file has </p>
<p>targetUrl=https://foobar:9080/foo</p>
<p>I am getting a malformed exception error. Do you think I am missing something?</p>
<p>Also, how do we read integer values from the properties file?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prabhat Atri</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-java/comment-page-1/#comment-220</link>
		<dc:creator>Prabhat Atri</dc:creator>
		<pubDate>Wed, 23 Jul 2008 10:01:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/read-java-properties-file/#comment-220</guid>
		<description>For web applications we can put the .properties file inside your src folder so that after build all the properties file gets reflected/copied to /WEB-INF/classes folder.

To access you can use following code snippet:

Properties props = new Properties();
	try
	{
		ClassLoader cl = UploadDealDocs.class.getClassLoader();
		InputStream fin = cl.getResourceAsStream.(&quot;./config.properties&quot;);
		props.load(fin);
		uploadedFilePath = props.getProperty(&quot;localDrivePath&quot;);
		fin.close();
	} 
	catch (Exception e1) 
	{
		LOG.info(&quot;FILE CANNOT BE READ&quot;);
		e1.printStackTrace();
	}  

Cheers :)</description>
		<content:encoded><![CDATA[<p>For web applications we can put the .properties file inside your src folder so that after build all the properties file gets reflected/copied to /WEB-INF/classes folder.</p>
<p>To access you can use following code snippet:</p>
<p>Properties props = new Properties();<br />
	try<br />
	{<br />
		ClassLoader cl = UploadDealDocs.class.getClassLoader();<br />
		InputStream fin = cl.getResourceAsStream.(&#8220;./config.properties&#8221;);<br />
		props.load(fin);<br />
		uploadedFilePath = props.getProperty(&#8220;localDrivePath&#8221;);<br />
		fin.close();<br />
	}<br />
	catch (Exception e1)<br />
	{<br />
		LOG.info(&#8220;FILE CANNOT BE READ&#8221;);<br />
		e1.printStackTrace();<br />
	}  </p>
<p>Cheers <img src='http://www.zparacha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

