Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6284003

Add setWriteOnly() to java.io.File

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 5.0
    • core-libs
    • b51
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      A mechanism for setting the permissions of a file exists for setting the file to READ only access. The inverse mechanism WRITE only acces does not exist.

      JUSTIFICATION :
      If you're going to be creating a file for use by another application, java or otherwise, the simpliest way to prevent another application from reading the file, prior to you being completely done with it, is to create the file as write only. Being able to alter the file to write only just after creation would be acceptable as well.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The java.io.File object would have a method called setWriteOnly( boolean flag). If called with a "true" then the file's permissions would be altered such that no user would be able to read the file. Under unix this would be to remove all of the write bits from the permission mask. If called with false then the file's permissions would either be reverted to the permissions prior to setting to write only, or more simply all of the write bits would be set in the permissions mask.

      CUSTOMER SUBMITTED WORKAROUND :
      Runtime.getRuntime().exec( "chmod 0222 " + file.getAbsolutePath() ).waitFor();
      ###@###.### 2005-06-10 17:00:55 GMT

            sherman Xueming Shen
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: