Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Question in File searching

 
Vasantha Prabha
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
if(fl.exists())
{
System.out.println("Yes the file is present");
}
else
{
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,
Sangeetha
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.,
 
Vasantha Prabha
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey In the case If Iam working in weblogic server
If I consider I know only the virtual path like
http://localhost:7001/jsp/test.jsp
Here in this test.jsp file
**********test.jsp
<html>
<%@ page language="java" %>
<%@ page import="example" %>
<jsp:useBean class="example" scope="request" id="Bn" >
<jsp:......
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
c:\weblogic\myserver\public_html\jsp\work.txt
But I want to Know whether I could searhc for file with
the virtual path
http://localhost:7001/jsp/

Regards,
Sangeetha
 
El Durango
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks El Durango I'll with this ...
Regards,
Sangeetha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic