How to check whether a file got read permissions for perticular user

Problem: Let JRE is running with some x as effective user in LINUX then while checking file permission it is checking permission on that file for that x user.
File f = new File(�file name�)
if(f.exists())
     System.out.println(�exists�);
Else
     System.out.println(�does not exists�);
The above code prints exists only when x user have permissions on that file
Requirement: I would like to check whether a file got read permissions for particular user i.e. whether y user got permissions on that file.
Any help is appreciated

In Linux a user has to have read permission on a file to even see that it exists. As a result, if a user (or a group to which they belong) doesn't have read access to the file File.exists() will return false. Windows which doesn't have as tightly controlled access to files will admit that a file exists whether it can be read or not.
PS.
This is proof that I should never answer a question off the top of my head when I haven't had my red bull yet. This is wrong. You will be able to see it if you have read and execute on the directory.
thumps self in head
Message was edited by:
puckstopper31

Similar Messages

  • How to check Whether the File is in Progress or used by some other resource

    Hi All,
    I am retrieving a file from the FTP server using Apache commons FTP.
    I need to check whether the file is fully retrieved or in progress.
    for now i can able to use the file which is partially retrieved. it is not throwing any file sharing exception or i am unable to find whether it is in progress.
    How to check whether the file is in progress ? or The file is accessed by some other resource ?
    Pls Help me.
    Thanks,
    J.Kathir

    Hi Vamsi,
    Explicitly such kind of requirement has not been catered and i dont think you would face a problem because any application that is writing to a file will open the file in the read only mode to any other simultaneous applications so i think your concerns although valid are already taken care off .
    In the remote case you still face a problem then as a work around. Tell the FTP administrator to set the property to maximum connections that can be made to ftp as one. I wonder if you have heard of the concept of FTP handle , basically the above workaround is based on that concept itself. This way only one application will be able to write.
    The file adapter will wait for its turn and then write the files.
    Regards
    joel
    Edited by: joel trinidade on Jun 26, 2009 11:06 AM

  • How to check whether a file exist in the program folder or not?

    Hi guys,
    how to check whether a file exist in the program folder or not? Let is say i recieve a file name from user then i want to know if the file is there not and act on that base.
    abdul

    Look at the class java.io.File and the .exists() method:
    http://java.sun.com/j2se/1.4/docs/api/java/io/File.html

  • How to check whether follow on document is created for sc or po,is there any table or fm available?

    How to check whether follow on document is created for sc or po,is there any table or fm available?

    Hello Venu
    Check FM: BBP_PD_SC_GETDETAIL and BBP_PD_PO_GETDETAIL table E_HEADER_REL
    Check this: SRM Shopping cart and PO tables link
    Regards

  • How to know whether a vacation rule is set for a user

    Hi,
    How to know whether a vacation rule is set for a user or not in the BPM process. Can anyone help me in this.
    Thanks,

    In Linux a user has to have read permission on a file to even see that it exists. As a result, if a user (or a group to which they belong) doesn't have read access to the file File.exists() will return false. Windows which doesn't have as tightly controlled access to files will admit that a file exists whether it can be read or not.
    PS.
    This is proof that I should never answer a question off the top of my head when I haven't had my red bull yet. This is wrong. You will be able to see it if you have read and execute on the directory.
    thumps self in head
    Message was edited by:
    puckstopper31

  • How to check whether a file is present in the UNIX directory of app. server

    Hi,
            I am creating files in the UNIX directory in the application server using :
                       CONCATENATE '/sapmnt/RD1/interfaces/client670/'
                       p_fname '.CSV' INTO w_filename.
               OPEN DATASET w_filename FOR OUTPUT IN TEXT MODE.
              LOOP AT t_output1.
                      TRANSFER t_output1 TO w_filename.
              ENDLOOP.
             CLOSE DATASET w_filename.
    I am unable to check whether a file with the same name exists or not. How to check the duplicate state of the file.

    You can use the following fm
    RZL_READ_FILE
    or
    use OPEN DATASET FOR INPUT.

  • How to check whether a file in AL11 is unicode or non-unicode

    Hi All,
    I have a file in AL11. Now before using open dataset, i need to check whether it is unicode or not. By doing this we will know what encoding format needs to be used with open dataset statement.
    Do we have any way by which we can programatically check whether a file in AL11 is unicode or not.
    Thanks,
    Tirth

    Hi,
    The code is as follows:
    IIndexService indexService = null;
    try {
       indexService = (IIndexService) ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.INDEX_SERVICE);
    } catch (ResourceException e) {
       if (indexService == null) {
         log.errorT("Error on instanciating the index service");
         return this.renderMessage(this.getBundleString(RES_NO_INDEX_SERVICE), StatusType.ERROR);
    // get index
    IIndex index = null;
    try {
       index = indexService.getIndex("YourIndexID");
    } catch (WcmException e1) {
       log.errorT("Error when trying to get the index");
       return this.renderMessage(this.getBundleString(RES_NO_INDEX), StatusType.ERROR);
    // check if the index is a instance of AbstractClassificationIndex
    AbstractClassificationIndex classiIndex = null;
    if (index instanceof AbstractClassificationIndex) {
       classiIndex = (AbstractClassificationIndex) index;
    } else {
       log.errorT("The index " + index.getIndexName() + " is no classification index");
       return this.renderMessage(this.getBundleString(RES_NO_CLASSIFICATION_INDEX), StatusType.WARNING);
    //give your KM Resource here for which you want to know if it is classified or not
    boolean classified = classiIndex.isDocClassifiedInAnyTax(resource);
    Regards,
    Praveen Gudapati

  • How to check whether MRP run has been executed for a sales order or not

    Dear Experts,
    In Strategy:20, Make to Order scenario, I have run MRP for sales order in T Code:MD50,
    then how can I check whether MRP run has been executed for a sales order or not.  Is there any report where I can find some indication?
    Thanks and regards,
    Vikas

    Dear,
    In MTO scenario with Planning strategy group 20 in material master .
    After sales order is created, Run MRP , then planned order will be created then go to planned order details in MD04 or MD12 you will get sales order number in assigment tab.
    or check the Table PLAF field  PALTR ,and field name KDAUF its sales order, for all created planned order.
    Regards,
    R.Brahmankar

  • How to check whether a file exists or not

    i am in an image uploading utility. i hav succesfully uploaded the image to the server directory (say /uploads). but when displaying the uploaded image, i wanna show the picture only if the image exits (bcoz for some records there is no image). so i hav used this code
    if(new File("uploads/1.jpg").exists())
         out.print("image exists");
    but its not working for me. i got it working fine when i give the full path "D:/Tomcat/webapps/diary/admin/uploads/1.jpg". but i think giving this absolute path is not an efficient method bcoz its a web application, bcoz i may not be able get the absolute path always. so how can i do this by specifieing the relative path
    help me ASAP if u can
    aleens

    Haii ameen
    This is one way to rectify your problem..
    if(new File("uploads/1.jpg").exists())
    out.print("image exists");
    instead of this u can write like
    <%
    ServletConfig cf=getServletConfig();
    ServletContext c=cf.getServletContext();
    if(new File(c.getRealPath("uploads")+"/test.txt").exists())
    out.print("image exists");
    %>If u are not clear of what it is done let me know..i will xplain to you furthur...
    Happy New Year
    Shanu

  • How to check whether INSO Filer is being used or not?

    Hi,
    We have created full text search indexes using the default syntax -
    CREATE INDEX FTI ON DOCUMENTS(DOC_FILE) INDEXTYPE IS CTXSYS.CONTEXT;
    How can I find out whether the INSO filter is used or not. Also a basic question, INSO filter helps in reading and "crawling" some 100+ document formats and creating an index against which search could be executed.... right?
    Please do let me know.
    Thanks & Regards,
    Dhwanil

    you can specify the inso filter in index code creation.
    create index TEST_IDX
    on TEST_TABLE (TEXT)
    indextype is ctxsys.context
    parameters('filter     ctxsys.inso_filter');

  • Files to download without any permissions for guest user.

    Hello, i have created a KM Navi Iview, with path to /documents/.../...
    When i go to
    http://portal/irj/portal/anonymous i see a list of files, but i can copy,delete and rename files (permissions for guest are: read), how can i solve this, if i need only download permissions for guest?

    Hello Artem,
    Please do not remove the Guest User from its groups.
    The Guest User is an integral part of the "Anonymous Users" group which ultmately falls under "Everyone" Group. How did you remove Guest User as only Config tool allows you to do that.
    What I suggest is make a Portal Group of Users and add all your regular users to it. Give Read/Write permission to this group. Then add only Read permissions for Anonymous Users Group.
    Hope this helped.

  • How to poll directory to check whether new file is added in plsql code

    How to poll directory to check whether new file is added in plsql code

    You can simply try opening that file for read in a loop (with some sleep in between). But in some OS (e.g. UNIX) file is accessible even if it is partially written. I suggest creating OK file (empty file with same name and OK as extension) after creating main file. This way PL/SQL code will be polling for OK file which means main file is completed.
    SY.

  • How to check whether file exist or not?

    hello,
    i wanted to know that how can i check whether a file exist or not independent of underlying Operating system?
    please help .
    Thank you.

    Use exists() on a File instance.

  • How to check whether there r new txt files in a folder n file creation date

    How to check whether there r new text files in a specified folder and what is the date of creation of the text file.........?

    Hi
    I have been searching for a solution to find the date of creation of a file for over 6 months now but haven't found it. So I presume that it is not possible though I havent found any authentication of my assumption in any document.
    Cheers!
    Shailesh

  • How to check whether the Application Server directory exits or not

    Hi,
    I have a selection screen in which I give the Application server file name(UNIX file) as input. Here, I would like to check whether the Server directory exists or not.
    Let us say, the path I gave in the selection screen is /usr/sap/tmp/testfile.txt . Here, the file name is testfile.txt and the server directory is /usr/sap/tmp . I would like to check whether this directory /usr/sap/tmp exists in the server or not. I am not bothered about the file name as I am going to write data into the file. I am mainly concerned about whether the directory exists in the server or not. and one more thing... this is the Application Server path not the Local path.
    Can anyone help me on the same how to check whether the server directory exists or not.
    Thanks in advance.
    Best Regards,
    Pradeep.

    Also you can use the FM EPS_GET_DIRECTORY_LISTING for this purpose.
      Store the directory name
        l_dpath = p_file+0(l_no).
      Validate the directory of the application server
        CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
          EXPORTING
            dir_name               = l_dpath
          TABLES
            dir_list               = l_i_dlist
          EXCEPTIONS
            invalid_eps_subdir     = 1
            sapgparam_failed       = 2
            build_directory_failed = 3
            no_authorization       = 4
            read_directory_failed  = 5
            too_many_read_errors   = 6
            empty_directory_list   = 7
            OTHERS                 = 8.
      If any problem occurs with the directory then display proper
      error message
        IF sy-subrc <> 0.
        Display error message
          MESSAGE e018 WITH 'Problem with directory entered'(008).
        ENDIF. " sy-subrc <> 0
    Regards,
    Joy.

Maybe you are looking for

  • My Mid-2010 MacBook Pro continually crashes on Mavericks

    Since upgrading to Mavericks I have consistently had my MacBook Pro crash due to what looks like a some kind of panic. Any ideas? Here are the details I get when rebooted: Fri Jan  3 11:25:57 2014 panic(cpu 1 caller 0xffffff7f8575efac): "GPU Panic: [

  • Get all the XML elements in document with a given tag.

    I have a document marked up with XML Tags. I want an array or collection of all the elements in the document with the tag "red." I've tried both of these functions, neither seem to work right: var redElements = myDocument.xmlElements.itemByName("red"

  • SCOPE_IDENTITY() blocking

    First, some background....  Long-standing system, multiple applications and web apps communicating with SQL Server through a farm of load-balanced app servers.  The app servers are running a common "business object" that we refer to as the data-sourc

  • Jumanji web browser very slow when trying to open a new website

    Duckduckgo and pwmt.org work just fine but everything else I tried just does not open. What can be the couse of this issue? Why would one website work just fine and another just refuse to open at all? Last edited by khajvah (2014-11-10 19:55:25)

  • Solaris Volume Manager - Unable to write to root disk with RAID1

    I setup my mirror, sub-mirror, and meta database to enable SVM to use raid1. When I change my vfstab to the meta locations I am able to boot, but are unable to write on the disk. Does anyone know why this might be happening that may cause my root dis