<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Interview Questions &#187; Java Saving a File</title>
	<atom:link href="http://www.bestjavainterviewquestions.com/category/java-interview-questions/io-questions/java-saving-a-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestjavainterviewquestions.com</link>
	<description>Java Interview Questions &#124; Core Java Interview Questions &#124; Advanced Java Interview Questions &#124; EJB Interview Questions &#124; J2EE Interview Questions &#124; Hibernate Interview Questions</description>
	<lastBuildDate>Fri, 03 Feb 2012 10:23:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a Text file using Java</title>
		<link>http://www.bestjavainterviewquestions.com/522/</link>
		<comments>http://www.bestjavainterviewquestions.com/522/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 17:06:22 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Saving a File]]></category>
		<category><![CDATA[saving a file using java]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=522</guid>
		<description><![CDATA[//Write a java program for creating a text file import java.io.*; import java.io.OutputStream; class FileAccess { public static void main(String args[])throws IOException { //Attach keyboard to DataInputStream DataInputStream dis=new DataInputStream(System.in); //Attach myfile to fileoutputstream FileOutputStream fos=new FileOutputStream(&#8220;xxxx.txt&#8221;); //read data from datainputstream and write it into fileoutputstream ObjectOutputStream p=new ObjectOutputStream(fos); char ch; System.out.println(&#8220;Enter date(@ to end [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>//Write a java program for creating a text file </em></strong></p>
<p><em>import java.io.*;<br />
import java.io.OutputStream;</em></p>
<p><em>class FileAccess<br />
{<br />
public static void main(String args[])throws IOException<br />
{</em></p>
<p><em>//Attach keyboard to DataInputStream</em></p>
<p><em>DataInputStream dis=new DataInputStream(System.in);</em></p>
<p><em>//Attach myfile to fileoutputstream</em></p>
<p><em>FileOutputStream fos=new FileOutputStream(&#8220;xxxx.txt&#8221;);</em></p>
<p><em>//read data from datainputstream and write it into fileoutputstream</em></p>
<p><em>ObjectOutputStream p=new ObjectOutputStream(fos);<br />
char ch;<br />
System.out.println(&#8220;Enter date(@ to end the program);&#8221;);<br />
while((ch=(char)dis.read())!=&#8217;@')<br />
fos.write(ch);<br />
p.writeInt(12345);<br />
p.writeObject(&#8220;Today&#8221;);<br />
p.putFields();</em></p>
<p><em>//p.writeStreamHeader();</em></p>
<p><em>p.writeFields();</em></p>
<p><em>p.flush();</em></p>
<p><em>//closefikle</em></p>
<p><em>fos.close();<br />
}<br />
}</em></p>
<p><strong>Procedure:</strong></p>
<p>First compile the program and run the program then given the inputs as a string then exit that and u can fine the file in the destination u had specified</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>October 5, 2008 -- <a href="http://www.bestjavainterviewquestions.com/goto-statement-in-java/" title="GoTo statement in Java">GoTo statement in Java</a> (0)</li><li>March 20, 2009 -- <a href="http://www.bestjavainterviewquestions.com/life-cycle-of-stateless-session-bean/" title="Life Cycle of stateless session bean">Life Cycle of stateless session bean</a> (0)</li><li>November 27, 2008 -- <a href="http://www.bestjavainterviewquestions.com/making-a-frame-non-resizable-in-java/" title="Making a Frame Non-Resizable in Java ">Making a Frame Non-Resizable in Java </a> (0)</li><li>September 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-cookie-poisoning/" title="Define Cookie Poisoning">Define Cookie Poisoning</a> (0)</li><li>August 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-earjar-and-war/" title="Define Ear,jar and war">Define Ear,jar and war</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/522/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

