zoukankan      html  css  js  c++  java
  • 文件属性的设置

    -------------siwuxie095

       

       

       

       

       

       

    工程名:SetFileProperty

    包名:com.siwuxie095.file

    类名:SetFileProperty.java

       

       

    手动在工程上创建文件:

    在工程名:SetFileProperty 上,右键->New->Untitled Text File,

    输入任意文本,保存路径选择 SetFileProperty,命名为 test.file

       

     

    工程结构目录如下:

       

       

       

       

    代码:

       

    package com.siwuxie095.file;

       

    import java.io.File;

       

    public class SetFileProperty {

       

    public static void main(String[] args) {

    //创建一个文件对象,命名为 test.file 后缀随意

    File file=new File("test.file");

     

    if (file.exists()) {

    //将文件设定为可写 传入布尔类型的参数

    file.setWritable(true);

     

    //将文件设定为可读 传入布尔类型的参数

    file.setReadable(true);

     

    //将文件设定为只读 无参(没有只写的对应的方法)

    file.setReadOnly();

    }

    }

       

    }

       

       

       

       

       

    【made by siwuxie095】

  • 相关阅读:
    获取枚举Description的Name
    MVC 3 RequiredIf validator for multiple values
    js关闭页面(兼容浏览器)
    js实现复制到剪切板
    Reverse Integer
    303. Range Sum Query
    326.Power of Three
    328. Odd Even Linked List
    面试基础知识点
    javaSE学习博客与笔记
  • 原文地址:https://www.cnblogs.com/siwuxie095/p/6612009.html
Copyright © 2011-2022 走看看