首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java 资料统计

2013-02-27 
java 文件统计import java.io.Filepublic class FileWrapper {private final static String REPLACEMENT_

java 文件统计

import java.io.File;public class FileWrapper {private final static String REPLACEMENT_STR = "*";private final static String REPLACEMENT_PATTERN = "0{1,}\\d{2}";private String fileWrapperName;private String location;private String fileSimpleName;private long size;private int page;private String next="";private String prefix="";@Overridepublic String toString() {// TODO Auto-generated method stubreturn this.getFileWrapperName()+","+prefix+this.getLocation()+","+this.getSize()+","+this.next+",";}public FileWrapper(String filePath) {super();this.location = filePath;//System.out.println(filePath);File file = new File(filePath);this.setSize(file.length());setKey();}public String getKey(){return this.getFileWrapperName();}public void setKey(){String location = this.getLocation();String key = extractKey(location);this.setFileWrapperName(key);}public static String extractKey(String location) {String strArray[] = location.split("\\\");StringBuffer sb = new StringBuffer();int startIdx = 0;for(String s :strArray){startIdx++;if(startIdx>3){sb.append("\"+s);}}return sb.toString().replaceAll(REPLACEMENT_PATTERN, REPLACEMENT_STR);}public String getFileWrapperName() {return fileWrapperName;}public void setFileWrapperName(String fileWrapperName) {this.fileWrapperName = fileWrapperName;}public String getLocation() {return location;}public void setLocation(String filePath) {this.location = filePath;}public String getFileSimpleName() {return fileSimpleName;}public void setFileSimpleName(String fileSimpleName) {this.fileSimpleName = fileSimpleName;}public long getSize() {return size;}public void setSize(long size) {this.size = size;}public int getPage() {return page;}public void setPage(int page) {this.page = page;}public void appendNext( FileWrapper wrapper) {// TODO Auto-generated method stubnext = wrapper.getLocation()+","+wrapper.getSize();}public void apendPrefix() {// TODO Auto-generated method stubprefix+=",,";}}

热点排行