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

Which collection is ordered in java?

972


What is an example of a constant variable?

1087


What is boolean strategy?

1133


Can an unreferenced object be referenced again?

1193


What is substring 1 in java?

1159


Can we declare register variable as global?

931


Why is stringbuffer called mutable?

994


What does || mean in code?

1038


What is lazy programming?

1039


How do I convert a numeric ip address like 192.18.97.39 into a hostname like java.sun.com?

1006


If you do not want your class to be inherited by any other class. What would you do?

1004


How many bytes is a string in java?

994


Does list allow duplicates in java?

930


how we can make a write-only class in java?

1024


Explain the difference between an object-oriented programming language and object-based programming language?

983