RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>Java>列表

采用多线程自动监视并扫描指定文件夹中的文件变化

来源: 作者: 时间:2007-09-29 点击:
, 17:59:55
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package DirectoryScanner;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
*
* @author Administrator
*/
public class ParseUtility {

public ParseUtility(){
}

public static String toYYYYMMDDHHMMSS(long time) {
SimpleDateFormat format = new SimpleDateFormat("MdHms");
return format.format(new Date(time));
}

public static String bytes2kb(long bytes) {
BigDecimal filesize = new BigDecimal(bytes);
BigDecimal megabyte = new BigDecimal(1024 * 1024);
float returnValue = filesize.divide(megabyte, 2 , BigDecimal.ROUND_UP).floatValue();
if (returnValue
1)
return(returnValue + " MB");
BigDecimal kilobyte = new BigDecimal(1024);
returnValue = filesize.divide(kilobyte, 2 , BigDecimal.ROUND_UP).floatValue();
return (returnValue + " KB");
}

}


最后是调用程序
:

/*
* FileMonitorTest.java
*
* Created on 2007
9

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册