473,406 Members | 2,390 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,406 software developers and data experts.

System cannot find the path specified

I'm having trouble reading in an xml file. My servlet retrieves the file path from the init parameters without a problem, but when I try to create a FileInputStream I get this:

javax.servlet.ServletException: \WEB-INF\classes\specialInstructions\specialInstruction s.xml (The system cannot find the path specified)

My file is there, and I can read it in if I create a URL.

ex:
Expand|Select|Wrap|Line Numbers
  1. URL xmlPath = servletContext.getResource(this.filePath);
What I need is for this to be a File object. Would anyone have any ideas as to why my File isn't being found? And how do I find?
Aug 20 '08 #1
1 6300
Nepomuk
3,112 Expert 2GB
I've had a few tricky problems with files, so I'll just show you, what I do to solve them.
Expand|Select|Wrap|Line Numbers
  1. File myFile = new File("\\path\\to\\file.xml");
  2. System.out.println("The file \"" + myFile.getAbsolutePath() + (myFile.exists() ? "\" exists." : "\" doesn't exist."));
Then check the output - is the File path correct? Does that line say, that the file exists? Probably the path is just slightly wrong in some way. (e.g. missing letter or File.seperator(), extra characters, etc.)

If the file exists, the output would look like this:
The file "\path\to\file.xml" exists.
Does that help?

Greetings,
Nepomuk


PS.: In case you didn't know, the line
Expand|Select|Wrap|Line Numbers
  1. System.out.println("The file \"" + myFile.getAbsolutePath() + (myFile.exists() ? "\" exists." : "\" doesn't exist."));
is short for
Expand|Select|Wrap|Line Numbers
  1. if(myFile.exists())
  2.    System.out.println("The file \"" + myFile.getAbsolutePath() + "\" exists.");
  3. else
  4.    System.out.println("The file \"" + myFile.getAbsolutePath() + "\" doesn't exist.");
Aug 21 '08 #2

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
3
by: Loi | last post by:
Hi All, I use Bulk insert to put data to myTable. When the SQL server is in local machin, it works well. But when I put the data in a sql server situated not locally, then I get a error message...
0
by: SampathTangudu | last post by:
Hi, We are trying to use the Hash Tables for passing information from one aspx page to another aspx page. We are using the below code. IsolatedStorageFile isoStore =...
3
by: NickP | last post by:
Hi there, Today I try to compile an application of mine and I am getting a whole list of bizaar errors.... ------------------------------------------------ Error 1 The...
0
by: Francois Stander | last post by:
Hi, No matter how I tried, I could net get it right to add a reference to my vb.net project, displaying the correct path. I have ms word 2003, running xp pro, version 5.1.2600 service pack 2 I...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, my problem is about services. I try comment you all steps for my issue: My development environment: Windows XP SP2
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, my problem is about services. I try comment you all steps for my issue: My development environment: Windows XP SP2
2
by: Gilles Ganault | last post by:
Hello I'm trying to use urllib to download web pages with the GET method, but Python 2.5.1 on Windows turns the URL into something funny: ======== url = "amazon.fr/search/index.php?url=search"
2
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do this in C# by specifying the path to the *.ico...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.