XP系统下Java修改文件或文件夹属性的代码。
2009-11-09 15:33:36
文件属性配置类
package cn.sist.file;
public class FileProperty {
private int sysProperty = 0;
private int hiddenProperty = 0;
private int readProperty = 0;
private int arriveProperty = 0;
private boolean changeAll = false;
public FileProperty setChangeAll(boolean changeAll){
this.changeAll = changeAll;
return this;
}
public boolean getChangeAll(){
return this.changeAll;
}
protected int getArriveProperty() {
return arriveProperty;
}
public FileProperty addArriveProperty() {
this.arriveProperty = 1;
return this;
}
public FileProperty removeArriveProperty(){
this.arriveProperty = 2;
return this;
}
protected int getHiddenProperty() {
return hiddenProperty;
}
public FileProperty addHiddenProperty() {
this.hiddenProperty = 1;
return this;
}
public FileProperty removeHiddenProperty(){
this.hiddenProperty = 2;
return this;
}
protected int getReadProperty() {
return readProperty;
}
public FileProperty addReadProperty() {
this.readProperty = 1;
return this;
}
public FileProperty removeReadProperty(){
this.readProperty = 2;
return this;
}
protected int getSysProperty() {
return sysProperty;
}
public FileProperty addSysProperty() {
this.sysProperty = 1;
return this;
}
public FileProperty removeSysProperty(){
this.sysProperty = 2;
return this;
}
}
文件修改类
package cn.sist.file;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class FilePropertyChange {
private static final String xpCommand = "cmd /c attrib";
private static final String[] xpSysProperty = {"","+s","-s"};
private static final String[] xpHiddenProperty = {"","+h","-h"};
private static final String[] xpArriveProperty = {"","+a","-a"};
private static final String[] xpReadOnlyProperty = {"","+r","-r"};
/*
* defaultFileProperty onl
相关文档:
上一篇文章讲述了浅拷贝和深拷贝的含义,并且给出了浅拷贝的一个例子
这篇文章在那个例子的实现上作出修改,实现深拷贝,代码如下:
package com.test;
public class CloneTest
{
public static void main(String[] args)
{
Student s1 = new Student();
s1.setAge(20);
s1.setName("wudi");
School sch ......
个人简历
个人信息
姓名
:
朱金国
性别
:
男
出生日期
:
1988
年
1
月
9
日
Email
:
zhujinguo2009@gmail.com
  ......
package test;
import javax.annotation.Resource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
@javax.jws.WebService(targetNamespace = "http://test/", serviceName = "Web ......
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BubbleSort {
private static int a[] = new int[12];
private static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public static void bubbleSort(int a[], i ......
首先解释两个概念,何为序列化?何为反序列化?
序列化:将对象转化成流的过程称为序列化
反序列化:将流转化成对象的过程称之为反序列化
序列化与反序列化必须遵守的原则
a) Java对象
在java中要想使一个java对象可以实现序列化与反序列化,必须让该类实现java.io.Serializable接口
java.io.S ......