473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

4 Java questions please help

1) Implement (i.e., write the body of) the following method, countLines, that, given a BufferedReader parameter, counts and returns the number of lines of text in the corresponding file/stream.

public static int countLines(BufferedReader in) throws IOException
__________________________________________________ ____________

2) Implement a new version of the countLines method that catches the possible IOException exception and outputs an error message if such an exception is raised.

public static int countLines(BufferedReader in)
__________________________________________________ ____________

3) Implement the following method, sumLines, that, given a BufferedReader parameter, reads all the integer values appearing one per line in the corresponding file/stream and returns the sum of the integers. Make sure you catch and handle the possible IOException exceptions.

public static int sumLines(BufferedReader in)

__________________________________________________ ____________

4) Implement the following void method, copyFile, that, given a BufferedReader parameter and a PrintWriter parameter, copies the file/stream from the given BufferedReader to the file/stream of the given PrintWriter. Make sure you catch and handle the possible IOException exceptions.

public static void copyFile(BufferedReader in, PrintWriter out)
Nov 27 '07 #1
1 1634
Laharl
849 Expert 512MB
We can't write your code for you. Please try to start the problem and let us know where you have issues.
Nov 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.