raja
raja

Reputation: 4193

What are the possible exception occurs during copying file?

My program has to copy file from one folder to another folder. I have used InputStream and OutputStream to do he same. The file size is about 5GB. what are all the possible exception may occur during this process and how?. As i need mention the same in unit testcase document...Please help.

Upvotes: 0

Views: 655

Answers (3)

Zach Scrivena
Zach Scrivena

Reputation: 29539

As a general rule, checked exceptions don't pop out of thin air. They are explicitly declared to be thrown by the methods you use (check the Java API). A good IDE (e.g. NetBeans) would even automatically prompt you to catch or declare these exceptions whenever you encounter them. Besides, you wouldn't even be able to compile your code if you didn't handle these exceptions. You have been documenting all these exceptions with Javadoc right? =)

Upvotes: 0

David Grant
David Grant

Reputation: 14225

Also consider using NIO for file copying, as it is likely that you'll get better performance which should be noticable with such a large file:

Take a look at this post from JavaLobby, which shows a static file copy method using java.io.FileChannels to do the grunt work.

Upvotes: 1

willcodejavaforfood
willcodejavaforfood

Reputation: 44053

Look at the java docs for the methods you are using. Any Sun Java docs will mention exceptions that can be thrown by methods.

I am guessing FileNotFoundException, NullPointerException, IOException.

Upvotes: 3

Related Questions