How to find out the status of a file in java

Hi
I have an application that writes xml files anytime it is invoked. I am writing all unique files to a windows directory.
i also have an ftp client working on that directory that scans all the files and sends them to the server every few minutes.
I want to find a way using which all the files except the one that is being currently written by the application are transferred.
Is there a way to find out in java as to what file is being written to by the operating system at that point of time ? I have looked around for quite a long time and have not been able to find a solution to this problem.
Any help will be deeply appreciated.

out = new FileOutputStream(matcher.group(1)+".open" , true);
                      FileChannel ch = out.getChannel();
                                   FileLock lock =  ch.lock(0L, Long.MAX_VALUE, false);
                               // Connect print stream to the output stream          
                                   p = new PrintStream( out );
                        p.println ("\n" + parms.getProperty( value ) + "\n");
                              p.flush();
                        p.close();
                              lock.release();Ok, I tried implementing locks but I dont know why it is not working...An exception is thrown and nothing is wriiten to the file. I have employed a complete lock on the file so that no other JVM application can use it.
Actually this is a server that grabs data sent from an Iframe and writes it down to a temp file. I open a file input stream, lock it and then use a printwriter strream to write the realyed data to the file. Any inputs as to what is wrong with the code snippet above?????

Similar Messages

  • How to find out the format of a file?

    Is there any way to find out the format of a file?
    By format I mean binary, text, .doc, .rtf, etc. Please kindly help

    The unix file command:
    file *
    foo.doc ms-office file / word
    bar.png png image, 32x32 pixels, no transparency
    moo.hhml html text
    note that as in the last - file names are ignored, it works by checking the beginning of each file's data against it's database, and as in #2 it can sometimes see a lot more than just the file format.
    Don't know of a windows port, you could try cygwin

  • How to find out the number of threads created under java vm at runtime

    our application seems to have hit the max number of threads that can be created under vm and the vm will just hang after that. that behavior seems to be consistent from an article that I read earlier.
    I wonder any way that java app can find out the number of threads currently created under vm?
    thanks in advance!

    If you are not starting an extra thread group you can use the Thread.activeCount method. But this willnot return all the threads, as there are some jvm threads, i.e. garbage collector. Also if you are running on a Unix type operating system then you can send a signal to the jvm to give you a thread dump, i think the signal is sighup.
    If the application is hanging i would of thought that you have a deadlock situation rather then the JVM not being able to create new threads, roughly how many threads should be running ??

  • How to find out the version of JDBC driver in Java?

    Hi all,
    I would like to use Java to find out the version of JDBC driver that I currently use. That JDBC driver is from Oracle and the filename is "classes12.zip" for all version ( 8.1.x to 9.x ). Is any method to verify what version JDBC I currently use? Thanks a lot.

    DatabaseMetaData.getDriverVersion()
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getDriverVersion()

  • How to find out the status of "Mark As Approved" in the workflow

    Hi All,
       How can i change the field values for any workflow record once its set as "Mark As Approved".i.e, once the workflow record is set to "Mark As Approved"  the value "abc" should be assigned automatically to the field "category".
    Can anybody please suggest me on this...
    Regards
    Sireesha.
    Edited by: sireesha esukapalli on Jun 4, 2008 1:45 PM

    Hi Harrison,
         Thank you for your reply.
         Let me explain my requirement clearly.
        I want to assign a value automatically to a particular field say "Category" to "Training" whenever approver approves the workflow record by right-clicking on the selected workflow record and choose Workflow-> Mark As Approved.ie., the value should be assigned automatically when you choose "Mark As Approved".
    My doubt is how can i assign a value automatically when its approved ?
    As u said how can i trigger a workflow when its approved through Workflows->Mark As Approved.
    Please advice me on this..
    Can anybody please advice me...
    Thanks & Regards
    Sireesha.

  • How to find out the size of a file?

    Hi,
    I would like to determine the size of a file from my code. How is that possible? I do not find any appropriate method in the java.io.File class.
    Any help would be very appreciated!

    java.io.File.length()
    Returns the size of the file as a long. The number corresponds to the number of bytes in the file.

  • How to find out the encoding of a file

    How to findout the encoding of a file being read?
    Thanks in advance?

    It depends on the file.
    Sometimes it is possible by analysing the file contents. Other times you have to know a priori.
    And you are welcome.

  • Hw to find out the status of the program...? like active / inactive?

    Hi kindly let me know how to find out the status for the programs (like active / inactive).
    I have 100’s of zprograms; I want to know at a time which are all active and which are all inactive.
    I heard some table is there, but don’t know exactly, let me know if you have any idea…
    Akshitha.

    Hi akshitha,
    1. Active and Inactive status is stored in table REPOSRC.
    2.  Just goto that table in SE11/SE16,
         and enter (copy/paste) the list of your 100 programs.
    3. <b>In that there is a field R3STATE
       Where A= Active
                 I = Inactive</b>
    From there u can filter as per ur requirement.
    regards,
    amit m.

  • Hi all, How to Find out the table where Cutomer Enqu. status is Stored??

    How to Find out the Customer Inquiry Status.
    I am not able to find in which table Status of Customer Inquiry is Stored.
    Is There any FM to find out This.

    Please post your question in the right forum to have your query addressed soon...
    I think you can check JEST table all status

  • How to find out the number of songs in my iTunes 11 library

    How to find out the number of songs in my iTunes 11 library

    Welcome to the Apple Support Communities
    To see the number of songs, go to View menu > Show Status Bar, so the number of songs you have will appear at the bottom of the iTunes window

  • How to find out the tables that will be affected using a transaction

    Hi,
    How to find out the list of database tables that will be affected when we use a standard transaction(ex. VA01, MM01..)...?(like When we create a salesorder, which tables and which fields will be affected..?)
    Is there any transaction or a simple way to find out the solution?
    Thanks,
    Pradeep.

    Hi,
    Give transaction code and in menu(system- status),  double click onthe Program name.
    Check in TOP INCLUDE - you will find all the tables related to that transaction.
    Thanks,
    Anitha

  • How to find out the Satus of the Production Order

    HI,
    I want to know how can i find out the status of the Order like Flash order ,Qualification lot etc.
    Which function module to be used,
    Please help.

    Hi
    I am not sure about Flash order ,Qualification lot  but status of production order can be displayed  on production order level itself . Or table JEST .
    Neal

  • How to find out the primary and failover DNS name

    Hi;
    This sounds very stupid, but could some one please tell me how to find out the name/dns name of the primary and failover server without using the CDS console.
    any help is appreciated

    Is this what you want?
    $ /usr/lib/ldap/ldap_cachemgr -g
    cachemgr configuration:
    server debug level 0
    server log file "/var/ldap/cachemgr.log"
    number of calls to ldapcachemgr 12729
    cachemgr cache data statistics:
    Configuration refresh information:
    Previous refresh time: 2005/08/07 23:54:59
    Next refresh time: 2005/08/08 00:55:00
    Server information:
    Previous refresh time: 2005/08/14 15:15:00
    Next refresh time: 2005/08/15 03:15:00
    server: ldap1.example.com, status: UP
    server: ldap2.example.com, status: UP
    server: ldap3.example.com, status: UP
    Cache data information:
    Maximum cache entries: 256
    Number of cache entries: 0
    Gary

  • How to find out the selected item in the lsit

    Hi all,
    How to find out the selected item in the list,can any please post some examples which easy to understand,because iam not a good programmer

    This sample program uses a checkbox as selection,  you could also use a HOTSPOT.
    report zrich_0002 no standard page heading.
    data: imara type table of mara with header line.
    data: check_box(1) type c,  
       report_lines type i.
    start-of-selection.
    * Create the gui status with BACK button in standard place
    * and a READ button in the application toolbar
      set pf-status 'CHECK'. 
    select * into corresponding fields of table imara           from mara up to 100 rows.
    loop at imara.   
    write:/ check_box as checkbox, imara-matnr, imara-matkl.  
    hide imara-matnr. 
    endloop.
      report_lines  = sy-linno - 1.
    top-of-page. 
    write: 'List of materials'.  uline.
    top-of-page during line-selection.  write:  'Material.....'.  uline.
    at user-command. 
    case sy-ucomm.  
    when 'READ'.   
      check_box = space.    
    set pf-status 'CHECK' excluding 'READ'.
          do report_lines times.       
    read line sy-index field value check_box.    
       if check_box = 'X'.        
    write:/  'You have selected material',
    imara-matnr.       
    endif.   
      enddo. 
    endcase.
    Regards,
    Rich Heilman

  • How to find out the last time login for a locked login account?

    In ASE 15.4,there are many login account show as locked and unlocked. How to find out the last login time for those locked login account?

    Thank you.  The version of my ASE is 12.5.4.
    This is what I got from select * from syslogins: 
    suid status accdate totcpu totio spacelimit timelimit resultlimit dbname name password language pwdate audflags fullname srvname logincount procid
    1
    30 2 10/25/2012 11:41:10.430 AM 0 0 0 0 0 . . ... us_english 02/24/2.0.08 12:55:38.640 PM 0 [NULL] [NULL] [NULL] [NULL]
    this is what I got from exec sp_displaylogin 'mylogin':
    1 Suid: 46                               
    2 Loginame: mylogin   
    3 Fullname: FN LN
    4 Default Database: mydb
    5 Default Language: us_english   
    6 Auto Login Script:    
    7 Configured Authorization:   
    8 Locked: YES                              
    9 Date of Last Password Change: Apr 17 2010  2:36PM    
    10 Password expiration interval: 0            
    11 Password expired: NO                               
    12 Minimum password length: 6            
    13 Maximum failed logins: 0            
    14 Current failed login attempts:    
    15 Authenticate with: AUTH_DEFAULT                     
    which one is for last login time?

Maybe you are looking for