Home > Java > javaTutorial > body text

How to set file attributes in java

WBOY
Release: 2023-05-15 08:01:12
forward
1025 people have browsed it

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();//只读
    }
  }
}
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template