How to know if the path given exists or not???

i have a string containing a path (of a directory or a file(.pdf)
i want to test if the path given exist in the hard disc or not i have tested with file.canRead but there is no results
please help???

the path are estracted from a database and i will check if these patwh exists or not in the hard disc
this is the method ; it read from the 1 tabe ,the second (and test if inthis path there is any .pdf),the third (and test if inthis path there is any .pdf),
public void parcours()
/*2*/ {
String ParcDep="select code_dp from departement" ;
String ParcOrg="select code_or from organisme o,departement d where d.code_dp=o.code_dp and o.code_dp=? ";
String ParcSor="select code_so from sous_organisme so,organisme o,departement d where so.code_or=o.code_or and d.code_dp=o.code_dp and so.code_or=? ";
Statement st=autentif.getStatement();
try
/*3*/{
Connection connec=autentif.getConnection();
PreparedStatement ps = connec.prepareStatement(ParcOrg);
PreparedStatement ps1 = connec.prepareStatement(ParcSor);
ResultSet rsd = st.executeQuery(ParcDep);
while(rsd.next())
/*4*/ {
System.out.println("boucle departement");
String Dep=rsd.getString(1);
String chem="c:\\Etats_insaf\\".concat(Dep);
System.out.println(chem);
String DepChem=chem.concat("\\");
System.out.println(DepChem);
ps.setString(1,Dep);
ResultSet rso = ps.executeQuery();
while(rso.next())
/*5*/ {
System.out.println("boucle organisme");
String Org=rso.getString(1);
System.out.println(Org);
String chem1=DepChem.concat(Org);
String DepOrgChem=chem1.concat("\\");
System.out.println(DepOrgChem);
File dirOrg=new File(chem1);
/*System.out.println("le chemin de lorganisme est");
System.out.println(dirOrg);
System.out.println("esqu il existe :");
System.out.println(dirOrg.exists());*/
if(dirOrg.exists()==false){ System.out.println("le chemin de l organisme au dessus n existe pas");}
else{/*11*/
FilenameFilter filter = new FilenameFilter()
public boolean accept(File dirOrg, String name)
return name.endsWith(".PDF");
String[] childOrgp=dirOrg.list(filter);
System.out.println("le tableau");
System.out.println(childOrgp);
if (childOrgp == null)System.out.println("pas de doc pdfdans org");
else
{/*6*/
System.out.println("aaaaaaaaaaaaaaaaa");
System.out.println(childOrgp.length);
for(int i=0;i<childOrgp.length;i++)
{/*7*/
System.out.println("le chemin du doc .pdf dans lorganisme est");
System.out.println(childOrgp);
System.out.println("esqu il existe :");
System.out.println(dirOrg.exists());
Statement stat=autentif.getStatement();
String reqnum="select cod_ed.nextval from dual";
ResultSet rsnum=stat.executeQuery(reqnum);
rsnum.next();
int num1=rsnum.getInt(1);
System.out.println(num1);
String num= Integer.toString(num1);
System.out.println("num");
System.out.println(num);
System.out.println("bbbbbbbbbbbbbbbbbb");
String filename = childOrgp;
String nom=DepOrgChem.concat(filename);
System.out.println("oooooooooooooooo");
System.out.println(nom);
String typef1=filename.substring(0,filename.indexOf("."));
int lg=nom.length();
String nomfin=nom.substring(3,lg);
String req="insert into etat_d'edition (code_ed,path_ed,taille_ed,telecharger_ed,code_te,code_or,code_so) values '"+num+"','"+nomfin+"',null,null,'"+typef1+"','"+Org+"',null )";
System.out.println(req);
st.execute(req);
}/*7*/
}/*6*/
ps1.setString(1,Org);
ResultSet rss = ps1.executeQuery();
while(rss.next())
{/*8*/
System.out.println("boucle Sous organisme");
String Sor=rss.getString(1);
System.out.println(Sor);
String chem2=DepOrgChem.concat(Sor);
String DepOrgSorChem=chem2.concat("\\");
System.out.println(DepOrgSorChem);
File dirSor=new File(chem2);
System.out.println("le chemin du sous organisme est");
System.out.println(dirSor);
System.out.println("esqu il existe :");
System.out.println(dirSor.exists());
if(dirSor.exists()==false){ System.out.println("le chemin de l organisme au dessus n existe pas"); }
else{/*12*/
FilenameFilter filter1 = new FilenameFilter()
public boolean accept(File dirSor, String name)
return name.endsWith(".PDF");
String[] childSor=dirSor.list(filter1);
if (childSor == null)System.out.println("pas de doc pdf");
else
{/*9*/
for(int j=0;j<childSor.length;j++)
{/*10*/
Statement stat=autentif.getStatement();
String reqnum1="select cod_ed.nextval from dual";
ResultSet rsnum1=stat.executeQuery(reqnum1);
rsnum1.next();
int num2=rsnum1.getInt(1);
System.out.println(num2);
String num1= Integer.toString(num2);
System.out.println("num1");
System.out.println(num1);
String filename1 = childSor[j];
String nom=DepOrgSorChem.concat(filename1);
String typef=filename1.substring(0,filename1.indexOf("."));
int longu=nom.length();
String nomfin1=nom.substring(3,longu);
String req2 ="insert into etat_edition(code_ed,path_ed,taille_ed,telecharger_ed,code_te,code_or,code_so) values('"+num1+"','"+nomfin1+"',null,null,'"+typef+"','"+Org+"','"+Sor+"' )";
st.execute(req2);
}/*10*/
}/*9*/
}/*12*/
}/*8*/
}/*5*/
}/*11*/
}/*4*/
}/*3*/
catch(Exception ex)
System.out.println("ayayayayayayayaaaaaa");
System.out.println(ex.getMessage());
}/*2*/
it must test if all the path extracted exists or not but it go to the first department (because it exist) then it stops (because the second department dosnot exist)

Similar Messages

  • How to know whether the javascript is disabled or not while loading the jsp

    Hi,
    My query is like how to know whether the javascript is disabled or not while loading the Application main JSP in Mozilla browser.
    I want some Java code or JavaScript code.

    To the point, just let JS fire a specific HTTP request inside the same session.
    This can be done in several ways. 1) Create a hidden <img> element and set the `src` attribute so that it will request a (fake) image from the server. The server just have to intercept on this specific request. 2) Fire an ajaxical request and let the server intercept on it. You can use a Filter for this which sets a token in the session scope to inform that the client has JS enabled.

  • How to know whether the phone is replaced or not?

    Dear All,
    Please help in how to know whether Iphone 5 is replaced or not? I came to know that on replacement, imei number gets changed. please make me aware.

    Nobody here can make you aware.  You need to contact Apple directly.

  • How to know if the data model qry is not returning any data

    Hi
    If my report doesn't have data (meaning if the data model qry doesn't retreive any data), I wan't to show this text: "There is no data returned."
    My question is how would I know that the qry is not returning any data. I know I can create a text field, and write a trigger on it, to set it True or False depending on the fact that data is being returned or not.
    Thanks
    Shalu

    Hi,
    In Data Model create a summary column for function=count on one of your columns.
    Then for BeforeReport trigger you can write
    function BeforeReport return boolean is
    begin
    if :CS_RPT_NODATA > 0 then
    return (TRUE);
    end if;
    SRW.MESSAGE(300,'There is no data');
    return (FALSE);
    end;
    Regards, Gicu

  • How to know whether the file is opened or not

    Hi All,
    In the file handling,
    Before writing OPEN DATA SET, I want to know the file is already opened or not.
    Please help me out in this regard.
    Thanks and regards,
    Mallareddy

    Hi,
    Please try GET DATASET statement.
    Syntax:
    GET DATASET dsn.
    Extras:
    1. ... POSITION pos
    2. ... ATTRIBUTES attr
    In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. For details, see File Interface.
    Effect
    Used to get the properties of a file already open.
    You can use this statement without additions to determine whether the file is open.
    If the file is not open, an exception of the type CX_SY_FILE_OPEN_MODE is triggered.
    Regards,
    Ferry Lianto

  • How to check the given path is existing or not using sp_cmdshell

    Hi All,
       I am passing one path to the stored procedure, before executing code i want to check whether the path is given existing or not .
    By using sp_cmdshell we can know whether files are there are not but in case of my scenario i want to know the directory(folder) is existing or not because the source folder may be blank so it will not get the files there so stored procedure returning the
     File Not found as output.
    following is the code i am trying to retrieve this please suggest any other way to solve it.
    Create table #tableExists  (isValid varchar(255))
    Declare @path varchar(255)='DIR "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA "/B'
    INSERT INTO #tableExists 
    EXEC xp_cmdshell @path
    select * from #tableExists
    Regards,
    Niraj Sevalkar

    You can try the other two undocumented extended stored procedures as well:
    --EXEC master.dbo.xp_subdirs @pathName
    EXEC Master.dbo.xp_fileexist @pathName
    EXEC Master.dbo.xp_DirTree @pathName,1

  • How to check if the path exists and if not, create it

    I'm trying to check if the path given by the user already exists. In case it doesn't, I'd like to create a folder with name given in the same directory.
    Let's say path_1: "C:\folder1" and path_2: "C:\folder2", and suppose that folder1 exists but folder2 doesn't. Then if the path given by the user is the path_1, then ok, nothing happens, but if it is the path_2, then the programm should realize that it doesn't exist in C:\ and should ask you whether you want to create it or not.
    I know how to do that for files, but not for folders!
    Thanks in advance

    hi guys,
    i`m new at this so im gonne prob. ask a noob`s question...
    i have the same issue as in the title.
    but when i run :
                                              int a,b,c,d,folderexist=-1;
                                             switch (event)
                                                       case EVENT_COMMIT:
                                                                                 GetCtrlVal (panelHandle, PANEL_NAME, name);
                                                                                 folderexist = GetFileAttrs (name, &a, &b, &c, &d);
                                                                                 if (folderexist==-1)
                                                                                           MakeDir (name);
                                                                                           sprintf...........
                                                                                 else.......
    if the folder do exists it works perfectly.
    if it doesnt - it breaks the run and gives me the message :
                          NON-FATAL RUN-TIME ERROR: "NewScap.c", line 317, col 27, thread id 0x00001B98: Library function error (return value == -1 [0xffffffff]).
    (and mark the getfileattrs line in blue)
    and when i check the "folderexits" value it shows 2!? not 1 not 0 not even -1, but 2...
    can somone please help ?
    thanks 
    Adi.

  • How can I get the path of an existing file????

    Hi.
    I'm a newbie in Jsp development, so this question may appear trivial.
    How can I get the path into a String of an exixting file ..like ...
    String thepath = path_of("my file.txt");
    Thanks for your help.

    Try
    application.getRealPath("myFile.txt")

  • How do I set the PATH to use ImageMagick under PHP on my Server?

    Hi,
    I have the ImageMagick binaries installed. They are working in the terminal.
    But when I try to use it out of a php script on the webserver, it cant find the DYLD_LIBRARY_PATH.
    The manual says:
    Set the MAGICK_HOME environment variable to the path where you extracted the ImageMagick files. For example:
    export MAGICK_HOME="$HOME/ImageMagick-6.3.7"
    If the bin subdirectory of the extracted package is not already in your executable search path, add it to your PATH environment variable. For example:
    export PATH="$MAGICK_HOME/bin:$PATH"
    Set the DYLD_LIBRARY_PATH environment variable:
    export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib"
    I can do all this in the Terminal, but how and where do I set it, that it also works with the scripts on the webserver?
    Thanks and Regards,
    JO

    Joachim,
    I have not tested any of this but...
    If you are just using the default Mac OS X Server install of Apache and the PHP module, then Apache's path is /usr/bin:/bin:/usr/sbin:/sbin (when running under the user:group=www:www). Basically, if the server is running under that user and PHP inherits the basic PATH of that user's shell, then anything linked into those directories should be available to the scripts, i.e. link your ImagMagick bin and lib paths into /usr 's directories. See 'man ln' in Terminal. User www doesn't have a defined shell, though, so I don't know where the PATH comes from.
    Alternatively, you might be able to use Apache's env_module (on by default) to manipulate the PATH environment variable in a config file. See Apache's manual on environment variables.
    Another means is to utilize 'suexec' in Apache and switch the user:group of CGI execution, etc. to a actual user with a definable .bash_profile (or whatever shell you are using). There are security concerns with this. See Apache's manual on suexec. You may want to also consider compiling PHP as CGI.
    BTW: the new version of PHP has some new experimental native ImageMagick libraries built in. I assume it looks for the binaries in the usual places and/or may need to be compiled with their paths during ./configure.
    Larry

  • How can i get the path to config folder placed inside the jar file?

    Hi i have developed an RCP application using eclipse.
    In my application config directory is there.
    When i export my RCP application as JNLP Project the jar file is created which contains config folder inside it.
    When i download the application using java web start , how can i get the path to config folder placed inside the jar file?
    Will the config folder exists in local cache in my system?
    Help needed.
    -Deepak

    -- This works in CS6:
    tell application "Adobe InDesign CS6"
      set myDocument to active document
      set selectedRectangles to selection of myDocument
      set theGraphicsLink to file path of item link of (graphic 1 of (item 1 of selectedRectangles))
    --> "Macintosh HD:folder/folder/filename.tif"
    end tell

  • How can I specify the path in Form Builder 9.0

    Hi, everyone,
    could anybody tell me how can I specify the path in Form Buidler 9.0? there is problems when I want to attach library in form builder. thanks to Kuldeep RAwat and Natalia Vidal, I know I should specify the path, but I still don't know how to specify, how can I do?
    besides, when I run a form, sometime there will be a warnig:
    Please acknowledge message
    what's that meaning?
    thank you very much for your great help

    Shay Shmeltzer thank you very much for your so quickly response. I have modified the file and my form can run now!
    but, when I open my form, it always suggest me:
    FRM-10102: Cannot attach PL/SQL library TalbotStandard. This library attachment will be lost if the module is saved.
    so everytime I open my form, I must attach the library manully. I don't know the reason. do you know that or anybody else knows that? thank you very much!
    have a good weekend :-)

  • How do you see the path in Yosemite?

    How do you see the path in Yosemite? What is the command to reveal the path to any given file? Is it somewhere in Finder?

    This is even better:
    Open the Terminal application
    Enter the line below exactly as it appears (Copy/Paste may/not work: highlight the line of text > switch to the Terminal app > cmd-v):
             defaults write com.apple.finder _FXShowPosixPathInTitle -bool TRUE
    *Note: there are single spaces after 'defaults', after 'write', after 'com.apple.finder', after '_FXShowPosixPathInTitle', and after '-bool'
    Then hit enter
    That's it! Go ahead and Quit Terminal (cmd-Q).
    Now:
    Close any Finder windows you have open.
    Open a new Finder window, and it should look like this:
    You can then get rid of the path bar at the bottom:
    Finder Menu > View > Hide Path bar -- or just use the keyboard-shortcut: cmd-opt-P

  • How do I find the path (source) of a document in mavericks?

    how do I find the path (source) of a document in mavericks?

    See if you can find the file using this program
    EasyFind – Spotlight Replacement

  • How do I know if the apps are free or not if I already have them on my ipad??

    How do I know if the apps are free or not if I already have them on my ipad?? I have an ipad and it was open by another person's Apple ID and all the applications too. Now I have change the Apple ID by my name and I wanted to update the apps and I can't remember if the apps were free or not, and I don't want to delete them without knowing if they are free.

    When you buy an app the app is permanently allocated to the AppleID account you bought it through.  You can then download that app on up to five devices,  as many times as you want, without buying it again.  So deleting an App is not a big problem, you just log into your account in iTunes again, find the app, and instead of showing you a 'BUY' button it shows you a 'DOWNLOAD' or 'INSTALL' button.
    If you change the AppleID account  you use in your iPad then Apple will think you sold the iPad to someone else, and all the apps with that name will stop working anyway.
    But you can change the name and email address for an AppleID account, without moving to a new AppleID account, by following these instructions:
    http://support.apple.com/kb/ht5621

  • How to know whether the Content Type at Library level is Inheriting Parent Content type or not Using Powershell?

    Hi,
    How to know whether the Content Type at Library level is Inheriting Parent Content type or not using Powershell?
    Is there any property for that? Or Do I need to compare the Content type Id's at Site collection level and Library level?
    Any help would be greatly appreciated.
    Thank you,
    AA.

    Hi Ashok,
    For a content type, there is an attribute called Inherits, the value of this attribute determines whether the content type inherits fields from its parent content type when it is created.
    If Inherits is TRUE, the child content type inherits all fields that are in the parent, including fields that users have added.
    If Inherits is FALSE or absent and the parent content type is a built-in type, the child content type inherits only the fields that were in the parent content type when SharePoint Foundation was
    installed. The child content type does not have any fields that users have added to the parent content type.
    More information, please refer to the link:
    https://msdn.microsoft.com/en-us/library/office/aa544268.aspx?f=255&MSPPError=-2147217396
    Best Regards,
    Wendy
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

Maybe you are looking for

  • External hard drive no longer shows up on Desktop

    Hi everyone, I did what a good person should do with a tech issue and did a long search through forums before I resigned to bothering you all with it. I've had a 500GB Seagate FreeAgent GoFlex Media external hard drive for 6 months which up until thi

  • Recently PopClip stopped showing "Cut," "Paste," and other similar options

    Hello, Recently, PopClip stopped showing "Cut," "Paste," and other similar options. I haven't changed anything in the settings. Maybe this will help: 2013-06-04 18:55:22.886 PopClip[1167:707] [INFO] PopAppDelegate: PopClip Initializing. 2013-06-04 18

  • After going haywire, Firefox refuses to uninstall

    Firefox has stopped working. I therefore decided to uninstall and re-install it. It will not uninstall.

  • MSS: customizing standard toolbar - repainting of screen - other issues

    Hello, 1) In the System and Menu drop down menus there is a Print button.  Is there any way of moving that button so it appears on the tool bar by itself? 2)When you display an ALV report in the web browser it, the report expands only as big as the b

  • I erased all content on iphone 3g.

    i was about to sell my iphone to someone, and i didn't want any of my personal info to be accessible.  so, i thought i was deleting all pics, etc... however it seems that i deleted my entire operating system off iphone 3g. all i see in itunes which i