Home >Java >javaTutorial >How to set file attributes in java

How to set file attributes in java

WBOY
WBOYforward
2023-05-15 08:01:121044browse

File attribute settings

package com.file;

import java.io.File;

/**
 * Created by elijahliu on 2017/2/11.
 */
public class SetFileProperty {
  public static void main(String[] args){
    File file = new File("test.file");
    if (file.exists()){
      file.setWritable(true);//可写
      file.setReadable(true);//可读
      file.setReadOnly();//只读
    }
  }
}

The above is the detailed content of How to set file attributes in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete