Java OutputStream Write copyFilePermissions(File source, File target)

Here you can find the source of copyFilePermissions(File source, File target)

Description

Sets the file permissions of the given source file on the given target file.

License

Open Source License

Parameter

Parameter Description
source a parameter
target a parameter

Declaration

private static void copyFilePermissions(File source, File target) 

Method Source Code

//package com.java2s;
/* MOD_V2.0/*  w ww  . ja  v a2 s .c  o m*/
 * Copyright (c) 2012 OpenDA Association
 * All rights reserved.
 * 
 * This file is part of OpenDA. 
 * 
 * OpenDA is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of 
 * the License, or (at your option) any later version. 
 * 
 * OpenDA is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU Lesser General Public License for more details. 
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with OpenDA.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.io.*;

public class Main {
    /**
     * Sets the file permissions of the given source file
     * on the given target file.
     *
     * @param source
     * @param target
     */
    private static void copyFilePermissions(File source, File target) {
        if (source.canRead()) {
            target.setReadable(true, false);
        } else {
            target.setReadable(false, false);
        }

        if (source.canWrite()) {
            target.setWritable(true, false);
        } else {
            target.setWritable(false, false);
        }

        if (source.canExecute()) {
            target.setExecutable(true, false);
        } else {
            target.setExecutable(false, false);
        }
    }
}

Related

  1. copyFile(InputStream in, OutputStream out)
  2. copyFile(InputStream in, OutputStream out, boolean close)
  3. copyFile(InputStream inputStream, OutputStream outputStream)
  4. copyFile(OutputStream os, InputStream is)
  5. copyFile(String fileName, String newFileName)
  6. serialize(java.io.Serializable serializable, java.io.ObjectOutputStream oos)
  7. serialize(Object o, OutputStream out)
  8. serialize(Object obj, OutputStream out)
  9. serialize(Object obj, OutputStream out)