<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>filewriter &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/filewriter/</link>
	<description>Feed of posts on WordPress.com tagged "filewriter"</description>
	<pubDate>Sat, 18 May 2013 14:14:10 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Write to File in Java]]></title>
<link>http://bayurimba.wordpress.com/2012/11/08/write-to-file-in-java/</link>
<pubDate>Thu, 08 Nov 2012 03:09:26 +0000</pubDate>
<dc:creator>uDjo</dc:creator>
<guid>http://bayurimba.wordpress.com/2012/11/08/write-to-file-in-java/</guid>
<description><![CDATA[In this tutorial, I will show you how to write java program to write to a file. We will use the clas]]></description>
<content:encoded><![CDATA[In this tutorial, I will show you how to write java program to write to a file. We will use the clas]]></content:encoded>
</item>
<item>
<title><![CDATA[How to update XML in Java]]></title>
<link>http://erangatennakoon.wordpress.com/2012/05/05/how-to-update-xml-in-java/</link>
<pubDate>Sat, 05 May 2012 16:16:57 +0000</pubDate>
<dc:creator>admin</dc:creator>
<guid>http://erangatennakoon.wordpress.com/2012/05/05/how-to-update-xml-in-java/</guid>
<description><![CDATA[Last week, when I am working with ontologies I came up with a requirement to update a XML using Java]]></description>
<content:encoded><![CDATA[<p>Last week, when I am working with ontologies I came up with a requirement to update a XML using Java. I just want to modify the text of a child node of a give node in a DOM document. Only three steps you have to keep in mind,</p>
<ol>
<li>Read into the relevant node.</li>
<li>Update the text content.</li>
<li>Save it back to XML.</li>
</ol>
<p><!--more--></p>
<p>Suppose that I have the following XML and I want to update the text of Value node when the OntologyCat is 2.</p>
<pre class="brush: xml; title: ; notranslate" title="">
&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34; standalone=&#34;no&#34;?&#62;
&#60;RuleSet&#62;
     &#60;Rule&#62;
          &#60;OntologyCat&#62;0&#60;/OntologyCat&#62;
          &#60;OntologyCatName&#62;Status&#60;/OntologyCatName&#62;
          &#60;Value&#62;Online&#60;/Value&#62;
     &#60;/Rule&#62;
     &#60;Rule&#62;
          &#60;OntologyCat&#62;1&#60;/OntologyCat&#62;
          &#60;OntologyCatName&#62;Act&#60;/OntologyCatName&#62;
          &#60;Value&#62;false&#60;/Value&#62;
     &#60;/Rule&#62;
     &#60;Rule&#62;
          &#60;OntologyCat&#62;2&#60;/OntologyCat&#62;
          &#60;OntologyCatName&#62;Width&#60;/OntologyCatName&#62;
          &#60;Value&#62;OldValue&#60;/Value&#62;
     &#60;/Rule&#62;
&#60;/RuleSet&#62;
</pre>
<p>The complete code I have separated into three methods, which explains three key points above.</p>
<pre class="brush: java; title: ; notranslate" title="">
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

// This class shows you that how to update a XML in Java
public class UpdateXML {

     // Save the updated DOM into the XML back
     private void saveToXML(File file, Document doc) {
          try {
               TransformerFactory factory = TransformerFactory.newInstance();
               Transformer transformer = factory.newTransformer();
               transformer.setOutputProperty(OutputKeys.INDENT, &#34;yes&#34;);

               StringWriter writer = new StringWriter();
               StreamResult result = new StreamResult(writer);
               DOMSource source = new DOMSource(doc);

               transformer.transform(source, result);

               String strTemp = writer.toString();

               FileWriter fileWriter = new FileWriter(file);
               BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);

               bufferedWriter.write(strTemp);
               bufferedWriter.flush();
               bufferedWriter.close();
          }
          catch(Exception ex) {
          }
     }

     // Read into the relevant node and update the text value
     private void updateTextValue(Document doc, String oldValue, String newValue) {
          try {
               Element root = doc.getDocumentElement();

               // Return the NodeList on a given tag name
               NodeList childNodes = root.getElementsByTagName(&#34;Rule&#34;);

               for(int index = 0; index &#60; childNodes.getLength(); index++) {
                    NodeList subChildNodes = childNodes.item(index).getChildNodes();
                    if(subChildNodes.item(1).getTextContent().equals(oldValue)) {
                         // Update the relevant node text content. item() position the NodeList.
                         subChildNodes.item(5).setTextContent(newValue);
                    }
               }
          }
          catch(Exception ex) {
          }
     }

     private void updateXML(File file, String strOldValue, String strNewValue) {
          DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();

          try {
               // Convert CDATA nodes to Text node append
               docFactory.setCoalescing(true);

               DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
               Document doc = docBuilder.parse(file);

               updateTextValue(doc, strOldValue, strNewValue);
               saveToXML(file, doc);
          }
          catch(Exception ex) {
          }
     }

     public static void main(String[] args) {
          File file = new File(&#34;c:\\doc.xml&#34;);
          new UpdateXML().updateXML(file, &#34;2&#34;, &#34;NewValueToUpdate&#34;);
     }
}
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Writer V/S BufferedWriter in java.]]></title>
<link>http://cleanjava.wordpress.com/2011/07/30/writer-vs-bufferedwriter-in-java/</link>
<pubDate>Sat, 30 Jul 2011 17:54:22 +0000</pubDate>
<dc:creator>cleanjava</dc:creator>
<guid>http://cleanjava.wordpress.com/2011/07/30/writer-vs-bufferedwriter-in-java/</guid>
<description><![CDATA[Today we will look at java character stream writer. Standard implementation FileWriter class is used]]></description>
<content:encoded><![CDATA[<p>Today we will look at java character stream writer. Standard implementation FileWriter class is used to write character stream into the underlying file system. FileWriter class provides API to write character by character, character array and String. BufferedWriter is a process stream used to decorate the IO/Character stream FileWriter. The process stream BufferedWriter helps to reduce the real IO operation, BufferedWriter comes with standard buffer size 8192. Programmer can pass in the size of the buffer on the time of instantiation based on the availability of main memory. BufferedWriter improve the performance of file writing with the help of in memory buffer that in turn reduce the IO operation.</p>
<pre class="brush: java; title: ; notranslate" title="">) throws IOException{
		
		FileWriterExample fileWriter = new FileWriterExample();
		fileWriter.write();
		fileWriter.writeThruBuffer();
	}
	
	private void write() throws IOException{
		Writer fileWriter = null;
		try {
			long startTime = System.currentTimeMillis();
			fileWriter = new FileWriter(new File(&#34;FileWriterExample.dat&#34;));
			for(int i=1000000; i&#38;gt;0; i--){
				fileWriter.write(i+&#34; ,&#34;);
			}
			System.out.println(&#34;Time Taken with out buffer : &#34;+
					(System.currentTimeMillis() - startTime));
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		finally{
			if(null != fileWriter){
				fileWriter.close();
			}
		}
	}
	
	private void writeThruBuffer() throws IOException{
		Writer fileWriter = null;
		try {
			long startTime = System.currentTimeMillis();
			fileWriter = new BufferedWriter(new FileWriter(new 
					File(&#34;BufferedFileWriterExample.dat&#34;)));
			
			for(int i=1000000; i&#38;gt;0; i--){
				fileWriter.write(i+&#34; ,&#34;);
			}
			System.out.println(&#34;Time Taken with buffer : &#34;+
					(System.currentTimeMillis() - startTime));
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		finally{
			if(null != fileWriter){
				fileWriter.close();
			}
		}
	}
}

</pre>
<p>Console output<br />
&#8212;&#8212;&#8212;&#8212;&#8211;<br />
/local/opt/java org.sanju.FileWriterExample<br />
Time Taken with out buffer : 640<br />
Time Taken with buffer : 529</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[JAVA - Using FileWriter]]></title>
<link>http://amilasurendra.wordpress.com/2009/04/23/java-using-filewriter/</link>
<pubDate>Thu, 23 Apr 2009 03:59:53 +0000</pubDate>
<dc:creator>amilasurendra</dc:creator>
<guid>http://amilasurendra.wordpress.com/2009/04/23/java-using-filewriter/</guid>
<description><![CDATA[Basic Usage of FileWriter Class. For More Info refer to API Docs - http://java.sun.com/j2se/1.5.0/do]]></description>
<content:encoded><![CDATA[<p>Basic Usage of FileWriter Class.<br />
For More Info refer to API Docs - <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/FileWriter.html">http://java.sun.com/j2se/1.5.0/docs/api/java/io/FileWriter.html</a></p>
<pre>import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class FileWriterDemo {
	public static void main(String args[]){
		try {

			// change filePath  as Desired.
			String filePath = "D:\\java.txt";

			//Create a new FileWriter Object
			FileWriter writer = new FileWriter(new File(filePath));

			// Writing to file. Can be String, Char, Char Array
			writer.write("This is a test File for demonstrate FileWriter. ");

			//terminate Filewriter
			writer.close();

		} catch (IOException e) {
			// Catch errors
			System.out.println(e.getMessage());
		}

	}
}</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Manipulando arquivos em JAVA]]></title>
<link>http://sl4v3r.wordpress.com/2008/09/25/manipulando-arquivos-em-java/</link>
<pubDate>Thu, 25 Sep 2008 23:11:44 +0000</pubDate>
<dc:creator>sl4v3r</dc:creator>
<guid>http://sl4v3r.wordpress.com/2008/09/25/manipulando-arquivos-em-java/</guid>
<description><![CDATA[Para manipular um arquivo podemos utilizar a classe FileWriter. Classse import java.io.BufferedWrite]]></description>
<content:encoded><![CDATA[<p>Para manipular um arquivo podemos utilizar a classe FileWriter.</p>
<p><strong>Classse</strong></p>
<p><span style="color:#008080;">import java.io.BufferedWriter;<br />
import java.io.FileWriter;<br />
import java.io.IOException;</span></p>
<p><span style="color:#008080;">public class GravaArquivo {<br />
    public void novoArquivo(String nomeArquivo, String texto) {<br />
        try {<br />
            BufferedWriter out = new BufferedWriter(new FileWriter(&#8220;nomeArquivo&#8221;));<br />
            out.write(texto);<br />
            out.close();<br />
        } catch (IOException e) {<br />
            e.printStackTrace();<br />
        }<br />
    }<br />
}</p>
<p></span> <strong>Utilização</strong></p>
<p>Para utilizar a classe é bem simples, basta instanciar a classe e utilizar o método novoArquivo.</p>
<p><span style="color:#008080;">private GravaArquivo arquivo;<br />
arquivo = new GravaArquivo();<br />
arquivo.novoArquivo(&#8220;c:\\arquivo.txt&#8221;, &#8220;testeeeee&#8221;);</span></p>
<p>flw</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[How to copy external files with Java and PL/SQL wrappers]]></title>
<link>http://maclochlainn.wordpress.com/2008/07/29/how-to-copy-external-files-with-java-and-plsql-wrappers/</link>
<pubDate>Tue, 29 Jul 2008 06:32:38 +0000</pubDate>
<dc:creator>maclochlainn</dc:creator>
<guid>http://maclochlainn.wordpress.com/2008/07/29/how-to-copy-external-files-with-java-and-plsql-wrappers/</guid>
<description><![CDATA[Moving forward with the external file architecture. The referenced page lets you copy external files]]></description>
<content:encoded><![CDATA[Moving forward with the external file architecture. The referenced page lets you copy external files]]></content:encoded>
</item>
<item>
<title><![CDATA[How to update a file in Java?]]></title>
<link>http://dadicy.wordpress.com/2007/10/12/how-to-update-a-file-in-java/</link>
<pubDate>Fri, 12 Oct 2007 04:26:02 +0000</pubDate>
<dc:creator>Cyrus</dc:creator>
<guid>http://dadicy.wordpress.com/2007/10/12/how-to-update-a-file-in-java/</guid>
<description><![CDATA[I&#8217;ve been reading books in Java just to find a code on how to update a file just to append a t]]></description>
<content:encoded><![CDATA[I&#8217;ve been reading books in Java just to find a code on how to update a file just to append a t]]></content:encoded>
</item>
<item>
<title><![CDATA[Manipulação de arquivo em Java]]></title>
<link>http://nodesign.wordpress.com/2006/08/31/8/</link>
<pubDate>Thu, 31 Aug 2006 12:56:00 +0000</pubDate>
<dc:creator>Anderson Gonçalves</dc:creator>
<guid>http://nodesign.wordpress.com/2006/08/31/8/</guid>
<description><![CDATA[Procurando curso de Android (sem precisar experiência em java) ?  http://treinamentos.visure.com.br/]]></description>
<content:encoded><![CDATA[Procurando curso de Android (sem precisar experiência em java) ?  http://treinamentos.visure.com.br/]]></content:encoded>
</item>

</channel>
</rss>
