How to check the existence of a file?

Hi,
I want to know how to use FileNotFoundException to check whether a text file exists in local directory.
How should I do the code?
Thanks
gogo

Like this:
private File f = new File ("c:\\projects\\sutil\\err\\temp_err.txt");
   if (f.exists()) {
      f.delete();
   }

Similar Messages

  • How to check the element  in xml file by xpath

    hi all,
    * How to check the element in xml file by xpath
    for the following XML file,
    * I want to check whether
    the element (sage) is present or not in the following xml file XPATH expression...
    * I have tried by the following expression ,
    NodeList result = (NodeList) xpath.evaluate("//*:student/*:sage/text()",xml_dom,XPathConstants.STRING);
    System.out.println(result.item(0).getLocalName()); * I want to get the Element sage as String value....
    but i am not able to get the element,why that ??? and How to do that ???
    MyXML File :
    <x:student>
    <x:sname>aaa</x:sname>
    <x:sage>26</x:sage>
    </x:student>
    Thanks,
    JavaImran

    <code>* Thanks for reply....
    * </code><code>In </code>
    <code>x:student element x represents the namespace...thats why i put *:student in my expression....
    "//*[local-name() = 'student']/*[local-name() = 'sage']/text()"* By the above code , i am not able to get the sage as string from
    </code> resul.item(0).getLocalName() method.......?
    * How to get that as string format ?

  • How to check the existence of file without any error dialog?

    Hi everybody,
    I am trying update some labview programs from LV6.1 to LV7.1, I used the
    function "File/Dictionary Info" to check if the file
    exists or not (if the size=0 then file does not exist), and it ran well with
    LV6.1, but now it shows every time a labview error dialog
    about "LabView: file not found..." with 7.1, if this file dosn't exist.
    Sometimes I feel that it is really stupid to show the dialog, because I
    can write handling by myself, if the error should be handled, and
    I don't want all the process is interrupted because of such dialogs. Is
    there any way to shut the dialog down or check the existence of
    file smoothly?
    Thanks a lot!
    L.Wang

    Hello,
    The dialog is probably appearing because you have Auto Error Handling turned on.  This feature is turned on by default in LabVIEW 7.0.  You should go to VI Properties (Ctrl-I) > Execution and deselect "Enable automatic error handling".  Also you should go to Tools > Options > New and Changed in LabVIEW 7.x and deselect "Enable automatic error handling in new VIs".  If you never want to see one of those dialogs again, you can also deselect "Enaeble automatic error handling dialogs"...I wouldn't recommend this, however, as you would never know if one of your VIs had this setting enabled...you would only find out once somebody else tried to use your VI on another LabVIEW install.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Checking the existence of a file b4 creating a file by the same name

    Hi All,
    I hav a scenario where I hav to check for the existence of a file by the same name (<b>XXXFile</b> say). If i don't hav any file by the name <b>XXXFile</b>, then i hav to create a file by the name <b>XXXFile</b> at that location. If it already exists, then i hav to wait till it gets deleted (takes hardly 1 min to get deleted).
    Can any one tell me :
    How to do this without using operating system command?
    And using operating system command?
    Any help wud be appreciated.
    Thnx in Adv
    Anil

    Hi Anil,
    You will i guess have a standard format in which you are going to write the file with a counter or something.
    Whenever you are going to write a file, you can:
    1. Check if there is a file already sent by this name?
    2. If no, then you can send the file at the same time update the name.
    You can do this by creating a ztable in SAP and accessing it through JCO/RFC. You can do this in your module or in the mapping.
    eg. /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i
    Regards
    Vijaya
    Message was edited by: vijaya kumari

  • How to check the contents of Control file, Log file & Parameter file

    Can anybody help me how i can check the contents of Control file, Log file & Parameter file.
    Arif

    OK ...
    Parameter file:
    It will normally be in the $ORACLE_HOME/dbs directopry. It could be aan init{sid}.ora or a spfile{sid}.ora ... do not edit an SPFILE as yu could corrupt it.
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14231/create.htm#sthref434
    If it's an init{sid}.ora, use any editor to see the actual content.
    If it's a spfile{sid}.ora, use one of V$PARAMETER, V$PARAMETER2, V$SYSTEM_PARAMETER, V$SYSTEM_PARAMETER2 as aappropriate (read the Reference manual to get an idea about when each is appropriate)
    Control File:
    You should not edit a control file. It consists of many areas, as described here http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14220/physical.htm#i10135 and each are is interrogated by V$views as given in the reference manual. The following V$views all deal with some aspect of the control file or provide info about the control files or the contents of control files:
    V$ARCHIVE_DEST
    V$ARCHIVED_LOG
    V$BACKUP_ARCHIVELOG_DETAILS
    V$BACKUP_CONTROLFILE_DETAILS
    V$BACKUP_CONTROLFILE_SUMMARY
    V$BACKUP_COPY_DETAILS
    V$BACKUP_COPY_SUMMARY
    V$BACKUP_CORRUPTION
    V$BACKUP_DATAFILE
    V$BACKUP_DATAFILE_DETAILS
    V$BACKUP_FILES
    V$BACKUP_PIECE
    V$BACKUP_REDOLOG
    V$BACKUP_SET
    V$BACKUP_SET_DETAILS
    V$BACKUP_SPFILE
    V$CONTROLFILE
    V$CONTROLFILE_RECORD_SECTION
    V$COPY_CORRUPTION
    V$DATABASE
    V$DATABASE_INCARNATION
    V$DATAFILE
    V$DATAFILE_COPY
    V$DATAFILE_HEADER
    V$DELETED_OBJECT
    V$LOCK
    V$LOG
    V$LOG_HISTORY
    V$LOGHIST
    V$OBSOLETE_BACKUP_FILES
    V$OFFLINE_RANGE
    V$PROXY_COPY_DETAILS
    V$PROXY_COPY_SUMMARY
    V$PROXY_DATAFILE
    V$RMAN_BACKUP_JOB_DETAILS
    V$RMAN_BACKUP_SUBJOB_DETAILS
    V$RMAN_CONFIGURATION
    V$SESSION
    V$TABLESPACE
    V$THREAD
    V$UNUSABLE_BACKUPFILE_DETAILS
    3) Log Files
    The contents of the log files are viewed using LogMiner - read Chapter 11 of the Oracle Utilities manual

  • How to check the existence of DB400 library from java

    Hi all,
    I actunally need to validate a DB400 library via java. so is there any way to check the existence of DB400 library from java side.
    Thanks in advance.

    Hi Sarvan,
    You might not even need a function to tell you if a record exists or not.
    Here in below example i do a check with exists .you will find couple of other ways too..
    create table t as select * from emp where deptno=10now i set salary of every person present in table 'T' to 1111 in emp table.
    update emp e
    set sal=1111
    where exists
            (select 1
              from t
              where t.empno=e.empno) Remember that plain SQL will always outperform PLSQL.
    Hope it helps
    CKLP
    Edited by: CKLP on Sep 26, 2011 3:41 AM

  • How to check the type of uploaded file

    Hi, experts,
    how can I check the type of the uploaded file? I am dealing with exception handling now: when user uploads a type of file which is not allowed, then error msg shows up. So first I have to retrieve the type of the uploaded file.
    Best regards,
    Fan

    Best approach would be to control the file upload program. Here in force user to chose only the kind of file supported.
    If you are using WD4A & fileupload UI element, then after user select a file to upload, before processing the file you can check the file name and get its MIME TYPE as shown below.
    example
    data type file string.
    data dot_offset type i.
    data extension type mimetypes-extension.
    data mimetype type mimetypes-type.
    file = 'Image.jpg'.
    " Find out file name extension
    find first occurrence of regex '\.[^\.]+$' in file match offset dot_offset.
    add 1 to dot_offset.
    extension = file+dot_offset.
    " Get mime type
    call function 'SDOK_MIMETYPE_GET'
      exporting
        extension = extension
    importing
        mimetype  = mimetype.
    later using if/else or CASE statement define your logic.
    Greetings
    Prashant
    P.S. Points Welcome

  • Checking the Existence of Flat File

    Hi,
    I want to know whether a flat file is existing in the presentation server.
    I want to check the text file's availability and upload if it is there using GUI Upload.
    Regards
    Anil

    Hi,
    Try this.
    AT SELECTION-SCREEN ON p_file.
      PERFORM f_validate_file.
    FORM f_validate_file .
    *VARIABLE DECLARATIONS
      DATA:loc_result TYPE abap_bool,
           loc_file TYPE string.
      loc_file = p_file.
    *Checking the file exist or not
      CALL METHOD cl_gui_frontend_services=>file_exist
        EXPORTING
          file                 = loc_file
        RECEIVING
          result               = loc_result
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          wrong_parameter      = 3
          not_supported_by_gui = 4
          OTHERS               = 5.
      IF loc_result = wl_space.
        MESSAGE e368(00) WITH text-003.  "ENTER CORRECT FILE PATH
      ENDIF.
    ENDFORM.                    " F_VALIDATE_FILE
    Regards,
    Rohan.

  • Checking the existence of  a file in the presentation/application server

    Hi All,
    If we have a filename with path, how do we check whether the file is existing in the presentation or application server?
    Thanks in advance,
    Regards,
    Bijesh

    hi,
    Please refer this thread. Solution is there.
    https://forums.sdn.sap.com/click.jspa?searchID=4091909&messageID=243700
    Rgds
    Reshma

  • How to check the existence of a storeProcedure

    Hello everyone,
    today I discovered how to call an oracle store procedure with jdbc classes, and it's been easy with tutorials and reading posts on this forum.
    The problem I have is the following:
    if i try to execute a store procedure which does not exist on the oracle schema with this code:
    try{         
    con = DriverManager.getConnection(databaseurl,username,password);
    cstmt = con.prepareCall"{call procedure_that_not_exist(?,?,?)}";
    cstmt.setString(1, "try");
    cstmt.registerOutParameter( 2, Types.VARCHAR );
    cstmt.registerOutParameter( 3, Types.VARCHAR );
    cstmt.executeUpdate();
    catch(Exception e)
    e.printStackTrace();
    System.out.println(e.getMessage());
    I get the following error:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'PROCEDURE_THAT_NOT_EXIST' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    how is it possible to check before getting this "not specific error" wheter the procedure exist on the database schema?
    Thank you!
    Gianni

    I mean the error PLS-00201 is not only related to the
    fact that the procedure does not exist, but more
    generally to "identifiers". (what are identifiers?)The 'name' of something. So, using your example code the following is an identifier....
    procedure_that_not_exist
    Other identifiers are variables in procs, table names, field names, constraint names, etc.

  • How to find the existence of a tag in  XML file through  XSLT Mapping?

    Hello Friends,
    Working on an SAP XI interface ,I have come across a situation where I need to map the values only when a particular tag exists in the inbound XML file.I need to use the XSLT mapping for the same.
    Requesting your advice on as to how may I validate the existence of a tag through XSLT mapping?
    Thanks.

    Hello Friends
    After research , I could also find another way to check the existence of a node .We can even use CHOOSE to check the existence.
    <xsl:choose>
          <xsl:when test="(/mynode)">
              your action if the mynode is found
          </xsl:when>
          <xsl:otherwise>
                    action if mynode is not found
          </xsl:otherwise>
    </xsl:choose>
    Thanks.
    Wishes
    Richa

  • How to check the resolution of a pdf file using Acrobat 9 pro?

    How to check the resolution of a pdf file using Acrobat 9 pro?

    PDF files don't have one resolution, but may have none or many different resolutions, one per image. You can check the maximum/minimum resoluion with preflight in Acrobat Pro, but not in Adobe Reader.

  • How to check the report builder version from the rdf file

    Hi,
    I have a rdf file but I don't the developer using which version of report builder to develop the rdf file. So, does anyone knows how to check the rdf file is developed by which version of report builder?
    When I try to use the notepad to open the rdf file, it shows the string "ROS.60050". So, does it means that the rdf file is developed by Oracle report 6i?
    Besides, do anyone knows if Oracle report 6i are still offer from Oralce (as I know, the latest verison of oracle report is 11g). So, in case Oralce not offer oracle 6i and I need to buy oracle report 11g, do u know it is compatiable or I need to do the migration from 6i to 11g?
    Thanks!

    Hi,
    The ROS version you are seeing in the RDF file does not mean the version where that RDF was developed. I am not aware of a way to check this but something that may help is that when you try to open a RDF developed in a higher version
    of Reports with a lower version of Reports builder the following warning will be displayed
    Warning. Opening a report saved with a newer version of Reports Builder.
    Functionality may be lost. Continue?
    "You tried to open a report with a version of Reports Builder older than the version used to
    create the report. If the report uses functionality unavailable in the older version, that
    functionality will be eliminated from the report.
    Regarding Oracle Developer 6i. This version is not supported any more. Regarding how to upgrade Reports 6i to 11g and what to have in mind during the upgrade please review the following documentation.
    References
    http://docs.oracle.com/cd/E24269_01/doc.11120/e24478/toc.htm
    How To Migrate Forms and Reports From 6i and/or 9i To 11g? (Doc ID 1275515.1)
    Hope it helps.
    Regards, RZ

  • How to check the JDK version of a compiled java file

    can anybody tell me how to check the JDK version of a compiled java file ?
    Edited by: gbhatia8 on Sep 9, 2010 7:04 AM

    The major/minor version of the class file is the way to go.
    Also, it's not necessary to write a separate program to get to those. javap prints them out when being passed the -v flag.
    Note, however that "JDK version" is not a correct term, as I can create 1.4-compatible class files with a Java 6 JDK (by passing the -target flag to javac). Those won't look any different than .class files written with a 1.4 JDK.

  • Checking for the existence of a file.

    I have a GUI to enter test info. A file is created based on the entered test number. I want to check for the existence of a file, and then notify the operator while not allowing the program to save it.

    This vi checks the presence of the input file.
    If file is not found, it will be created.
    regards
    ian.f
    Ian F
    Since LabVIEW 5.1... 7.1.1... 2009, 2010
    依恩与LabVIEW
    LVVILIB.blogspot.com
    Attachments:
    File_check_existance_openorcreate_2003.vi ‏72 KB

Maybe you are looking for

  • ERROR RENDERING PDF IN SERVLET WITH FORM method="post"

    Hello, we are trying to render a dinamic PDF document in a servlet building with XSL:FO apache or itext. The problem ocurs when we sending a Form data with method post, the output of the servlet is a blank page instead of the pdf document. Also if we

  • Loading drivers in java

    hai I have a doubt about the location from where certain drivers are loaded in java. for example "sun.jdbc.odbc.JdbcOdbcDriver " in the case of loading database driver and com.sun .image.codec.jpeg.JPEGCodec in the case of jpeg encoding I can't find

  • Where are the Adobe PDF Presets stored?

    I am doing some video lessons and would like to clean up the Adobe PDF Presets menu in the Export as PDF dialog box. Where are they stored? I've looked through the many folders on my machine called "Presets" but can't find them. Running Acrobat 10 un

  • Filename arrays in bash

    I want to make a filename array to use with ffmpeg under BASH.  For example there are six video files named video_1.h264, video_2.h264, video_3.h264, video_4.h264, video_5.h264 and video_6.h264. I want to then concat them using ffmpeg ffmpeg -i "conc

  • Allow and Remember does not work

    I have a Java message that I have to allow each time I am opening an encrypted email from a certain party. I click on "Allow and Remember" but each time I open a new email from this party the same message pops-up asking me to allow. How do I get arou