• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

A Question in File searching

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks El Durango I'll with this ...
Regards,
Sangeetha
 
This is my favorite show. And this is my favorite tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic