ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Read data from console and print in one file. That would be 
in C:\temp  ? Thanks, Bose
 Question Submitted By :: Bose
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Read data from console and print in one file. That would be in C:\temp ? Thanks, Bose
Answer
# 1
//Read data from console and print in one file. 
import java.io.*;
class  ReadDataFromConsole
{
	public static void main(String[] args) 
	{
		try{
			  String fileStr = ""; // declare a string variable
			  for(int i = 0; i<args.length; i++){ // for loop start
with  argument size
				   
					fileStr = fileStr + " " + args[i];
			   }
				  

				//create an instance of the random acces file "rfile'.
				RandomAccessFile rfile = new
RandomAccessFile("C:/Temp/text.txt","rw");
				// write object into the file.
				rfile.writeBytes(fileStr);
				 
			 
		}catch(Exception ex){
			ex.printStackTrace();
		
		}
	}
}
 
Is This Answer Correct ?    0 Yes 0 No
Pushpa
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Explain Stream Tokenizer?  3
When does the compiler supply a default constructor for a class? TCS8
What happens if an exception is not caught?  4
What is the Layout for ToolBar?  1
what is ennumaration? AMDOC1
what is meant by string pooling? Wipro6
What are hot spots in Java programming?  1
Explain final, finalize() and finally?  6
What is casting ?  2
What is meant by JVM ?  3
IS method overriding is Duplication of Methods? CybAge4
what is difference between Exception and Error?  14
Difference between overloading and overridding?  4
what is difference between throw and throws in exception?  16
Hi ,i convert contrller as jSp And presentation as servlet ...will it do? if so what are advantage and idsadvantages IBM1
why Runnable interface is preferable than extending the Thread class? Wipro5
what is difference between colection and collections? Tech-Mahindra8
how to transactions(Bank transactions) in business process in ejb? Photon1
different types of threads? TCS7
Is java supports multiple inheritance? explain? Inforica11
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com