Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Read data from console and print in one file. That would be
in C:\temp ? Thanks, Bose

Answer Posted / pushpa

//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 ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is default locale java?

1045


What are the advantages of defining packages in java?

923


What are internal variables?

940


What is the difference between stringbuffer and stringbuilder class?

1034


List some oops concepts in java?

978


Can inner class have constructor?

987


What are different ways of object creation in java ?

1018


Can I use % with real numbers?

962


Explain methods specific to list interface?

914


What are the Static and Dynamic Variables? Differentiate them.

1044


What is getclass () getname () in java?

1094


What is a priority queue java?

927


When is finally block not called?

1016


What is the difference between declaration and definition in java?

1000


How do you achieve polymorphism in java?

934