DFile implements Serializable, Comparable<DFile> { public static DFile parse(final File file){ DFile dFile=new DFile(); if(file==null) return dFile; String path=FilenameUtils.toDFSPath(file.getAbsolutePath()); dFile.setFilename(FilenameUtils.getName(path)) .setPath(path) .setParent(FilenameUtils.getFullPathNoEndSeparator(path)) .setSuffix(FilenameUtils.getExtension(path)) .setDirectory(file.isDirectory()) .setHostname(HostnameUtils.NAME) ; if(file.exists()){ javaxt.io.File xtFile=new javaxt.io.File(file.getAbsolutePath()); dFile.setAccessDate(xtFile.getLastAccessTime()) .setModifyDate(xtFile.getLastModifiedTime()) .setCreateDate(xtFile.getCreationTime()) .setContentType(xtFile.getContentType()) .setLength(file.length()) ; try{ dFile.setMd5(HexUtils.md5HexOfInputStream(xtFile.getInputStream())); }catch (Exception e){ } } return dFile; } DFile();  DFile(String os,InputStream is);  DFile(boolean isDirectory, String parent, String name, long length, InputStream is); static final DFile noExist(); static DFile parse(final File file); static DFile parse(String filePath); Map<String, Object> toMap(); InputStream getInputStream(); long length(); boolean isRoot(); void moveToDir(String targetDir); boolean isFile(); boolean isDirectory(); boolean exist(); String getAbsolutePath(); String getParent(); @Override int compareTo(DFile o); String getOs(); String getCategory(); DFile setCategory(String category); String getMd5(); DFile setMd5(String md5); String getSuffix(); DFile setSuffix(String suffix); String getFilename(); DFile setFilename(String filename); long getLength(); DFile setLength(long length); DFile setParent(String parent); DFile setDirectory(boolean directory); boolean isExist(); DFile setExist(boolean exist); String getPath(); DFile setPath(String path); String getHostname(); DFile setHostname(String hostname); String getContentType(); DFile setContentType(String contentType); String getAuthor(); DFile setAuthor(String author); Date getCreateDate(); DFile setCreateDate(Date createDate); Date getModifyDate(); DFile setModifyDate(Date modifyDate); Date getAccessDate(); DFile setAccessDate(Date accessDate); Date getUploadDate(); DFile setUploadDate(Date uploadDate); String getRemark(); DFile setRemark(String remark); Map<String, Object> getMetadata(); DFile setMetadata(Map<String, Object> metadata); static final String OS; static final boolean IS_WIN; static final String ATTR_DIRECTORY; static final String ATTR_MD5; static final String ATTR_PARENT; static final String ATTR_NAME; static final String ATTR_FILE_NAME; static final String ATTR_PATH; static final String ATTR_HOSTNAME; static final String ATTR_SUFFIX; static final String ATTR_OS; static final String separator; }
@Test public void path(){ DFile file=DFile.parse("D:"); System.out.println(JSON.toJSONString(file,true)); System.out.println(FilenameUtils.getPathNoEndSeparator("/D:/abc/ad/2")); }