my dog learned polymorphism
The moose likes Java in General and the fly likes A Question in File searching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "A Question in File searching" Watch "A Question in File searching" New topic

A Question in File searching

Vasantha Prabha
Ranch Hand

Joined: Oct 02, 2003
Posts: 108
Hey can any one help me out
I have a question in file searching ?

Here is the example.. Please have look over this
File fl=new File("/test.txt");
System.out.println("Yes the file is present");
System.out.println("No the file doesn't exists");
Here is my problem ...
my file is in the directory c:\users\work\test.txt
but the programm search for the file in c:\test.txt
and produce the result "Not exists".
I what my program to search in the current dirctory on which the
program file exists
can any one help me out...

Regards,Vasantha<p>Great minds discuss ideas. Average minds discuss events. Small minds discuss people.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

A path starting with a slash is an absolute path from the root of the disk. If you want a path relative to the current directory, don't use the slash -- i.e.,

[Jess in Action][AskingGoodQuestions]
Vasantha Prabha
Ranch Hand

Joined: Oct 02, 2003
Posts: 108
Hey In the case If Iam working in weblogic server
If I consider I know only the virtual path like
Here in this test.jsp file
<%@ page language="java" %>
<%@ page import="example" %>
<jsp:useBean class="example" scope="request" id="Bn" >
This is how my jsp programm goes off

where in the class
Iam searching for a file work.txt in the directory
in the actual path
But I want to Know whether I could searhc for file with
the virtual path

El Durango

Joined: Oct 09, 2003
Posts: 23
I use

within my servlet to access virtual paths within tomcat.
You can then append the exact directory paths within the virtualpath.
hope that helps
Vasantha Prabha
Ranch Hand

Joined: Oct 02, 2003
Posts: 108
Thanks El Durango I'll with this ...
I agree. Here's the link:
subject: A Question in File searching
It's not a secret anymore!