<?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: Java &#8211; Edit File Example, Modify File java</title>
	<atom:link href="http://www.easywayserver.com/blog/java-edit-file-example-modify-file-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.easywayserver.com/blog/java-edit-file-example-modify-file-java/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 15 Jan 2012 15:24:27 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: baxou</title>
		<link>http://www.easywayserver.com/blog/java-edit-file-example-modify-file-java/comment-page-1/#comment-19329</link>
		<dc:creator>baxou</dc:creator>
		<pubDate>Sat, 26 Mar 2011 22:29:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=484#comment-19329</guid>
		<description>Sorry for the indentation, I didn&#039;t know how to put it on (i thought it would take the spaces I made)</description>
		<content:encoded><![CDATA[<p>Sorry for the indentation, I didn&#8217;t know how to put it on (i thought it would take the spaces I made)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: baxou</title>
		<link>http://www.easywayserver.com/blog/java-edit-file-example-modify-file-java/comment-page-1/#comment-19328</link>
		<dc:creator>baxou</dc:creator>
		<pubDate>Sat, 26 Mar 2011 22:26:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=484#comment-19328</guid>
		<description>It is quite an interesting code which helped me a lot, but there are some clumsy things about it.

First of all using a while(true) loop is not a good idea. It would be better if you did it like this so it is easier to read :
            String textinLine=br.readLine();
            while(textinLine != null)
            {
                sb.append(textinLine + &quot;\n&quot;); // if you don&#039;t put the \n you will have all the code on one line as fer said
                textinLine=br.readLine(); // do not put the \n here unless you want to experience an exquisite exception.
            }

Then you should create a method to do replacements easier without needing to copy/paste the code each time, and besides, it is actually doing only one replacement and this is not kinda effective for people wishing to make multiple replacements. What do you think about this :

       // if you want to put this in the same class as your main do not forget to use the static keyword to declare the method
       public void replace(String textToEdit, String textToReplaceWith) { 
              int cnt = sb.indexOf(textToEdit);
              while(cnt != -1) { // so it will replace every occurence until there is no more left
                  sb.replace(cnt2,cnt+textToEdit.length(), textToReplaceWith);
                  cnt = sb.indexOf(textToEdit);
              }
       }

To continue these three lines of code are an error of logic since fs is used to create in which is used to create br :
              fs.close();
              in.close();
              br.close();
They should be reversed :
              br.close();
              in.close();
              fs.close();

Have a nice day.
</description>
		<content:encoded><![CDATA[<p>It is quite an interesting code which helped me a lot, but there are some clumsy things about it.</p>
<p>First of all using a while(true) loop is not a good idea. It would be better if you did it like this so it is easier to read :<br />
            String textinLine=br.readLine();<br />
            while(textinLine != null)<br />
            {<br />
                sb.append(textinLine + &#8220;\n&#8221;); // if you don&#8217;t put the \n you will have all the code on one line as fer said<br />
                textinLine=br.readLine(); // do not put the \n here unless you want to experience an exquisite exception.<br />
            }</p>
<p>Then you should create a method to do replacements easier without needing to copy/paste the code each time, and besides, it is actually doing only one replacement and this is not kinda effective for people wishing to make multiple replacements. What do you think about this :</p>
<p>       // if you want to put this in the same class as your main do not forget to use the static keyword to declare the method<br />
       public void replace(String textToEdit, String textToReplaceWith) {<br />
              int cnt = sb.indexOf(textToEdit);<br />
              while(cnt != -1) { // so it will replace every occurence until there is no more left<br />
                  sb.replace(cnt2,cnt+textToEdit.length(), textToReplaceWith);<br />
                  cnt = sb.indexOf(textToEdit);<br />
              }<br />
       }</p>
<p>To continue these three lines of code are an error of logic since fs is used to create in which is used to create br :<br />
              fs.close();<br />
              in.close();<br />
              br.close();<br />
They should be reversed :<br />
              br.close();<br />
              in.close();<br />
              fs.close();</p>
<p>Have a nice day.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fer</title>
		<link>http://www.easywayserver.com/blog/java-edit-file-example-modify-file-java/comment-page-1/#comment-19169</link>
		<dc:creator>fer</dc:creator>
		<pubDate>Sun, 20 Mar 2011 09:47:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=484#comment-19169</guid>
		<description>code is working but I have one problem, 
I have this record in my info.text
name: fern
age:20


after I replace the word of &quot;fern&quot;
it will make a one line &quot;   name: NEWNAMEage:20  &quot;
which is I want to keep the original position and just replace the word I want to replace.
please mail me how to do it. Tnx!</description>
		<content:encoded><![CDATA[<p>code is working but I have one problem,<br />
I have this record in my info.text<br />
name: fern<br />
age:20</p>
<p>after I replace the word of &#8220;fern&#8221;<br />
it will make a one line &#8221;   name: NEWNAMEage:20  &#8221;<br />
which is I want to keep the original position and just replace the word I want to replace.<br />
please mail me how to do it. Tnx!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vishakha</title>
		<link>http://www.easywayserver.com/blog/java-edit-file-example-modify-file-java/comment-page-1/#comment-14454</link>
		<dc:creator>vishakha</dc:creator>
		<pubDate>Wed, 10 Nov 2010 12:59:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.easywayserver.com/blog/?p=484#comment-14454</guid>
		<description>Thanks for your support, its really help me a lot.</description>
		<content:encoded><![CDATA[<p>Thanks for your support, its really help me a lot.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

