Showing posts with label File Based Programs. Show all posts
Showing posts with label File Based Programs. Show all posts

Saturday, November 23, 2013

Java BufferedReader & StreamTokenizer Example

Write a method that will take a string containing integers and return the sum of the numbers present in the string. For example, given the string "10 2 20 30" should print 62.

Java FileInputStream Example

Write a JAVA Program which reads an input file from the Command Line which contains the numbers sperated by space and find the average for the numbers.

Java File concatenation (Multiple file Handling)

Write a JAVA Program which reads a number of text files from the command line and concatenates the contents of the files into the last file entered on the command line.

Example:
Java Concatenate src1.txt src2.txt src3.txt dest.txt
All the contents of the source files should be concatenated and written in destination file.

Friday, November 22, 2013

Java File write operation from Console

Write a JAVA Program which accepts lines of text from the console until 'stop' is entered and prints the lines of text it read.

Sample Input & Output :
Enter lines of text
Enter 'stop' to quit
---------------------
India's plans to wrap up a quick nuclear deal with Russia
The Prime Minister arrived here yesterday to a red carpet welcome
Top government sources said lawyers of both the sides have to clear the text of the agreement
stop

The lines you entered are :
--------------------------
India's plans to wrap up a quick nuclear deal with Russia
The Prime Minister arrived here yesterday to a red carpet welcome
Top government sources said lawyers of both the sides have to clear the text of the agreement

Thursday, October 24, 2013

Java Program for concating File content

Write a JAVA Program which reads a number of text files from the command line and concatenates the contents of the files into the last file entered on the command line.

Example:

Java Concatenate src1.txt src2.txt src3.txt dest.txt

All the contents of the source files should be concatenated and written in destination file.