?
Solved

When file not found Exception occured i want to set the string  Errortext = file not found

Posted on 2011-05-11
2
Medium Priority
?
221 Views
Last Modified: 2012-05-11
When file not found Exception occured i want to set the string ErrorText = File Not Found
0
Comment
2 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 35744051
try{
//actual code here
}catch( FileNotFoundException fnfe ){
  errorText = "File not found" ;
}
0
 
LVL 1

Accepted Solution

by:
stephano12 earned 2000 total points
ID: 35744305
you could use this example:
       
   public static void main(String[] args) throws FileNotFoundException {
		File f = new File("example.txt");
		try {
			BufferedReader bf = new BufferedReader(new FileReader(f));
		} catch (FileNotFoundException e) {
			throw new FileNotFoundException("file not found");
		}
	}

Open in new window

public static void main(String[] args) throws FileNotFoundException {
		File f = new File("example.txt");
		try {
			BufferedReader bf = new BufferedReader(new FileReader(f));
		} catch (FileNotFoundException e) {
			throw new FileNotFoundException("file not found");
		}
		
	}

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This video teaches viewers about errors in exception handling.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question