java获取ubuntu某个目录下的所有文件信息
java获取ubuntu某个目录下的所有文件信息
public List<VCFile> getAllFiles(String basicDirName) { List<VCFile> listFile = new ArrayList<VCFile>(); SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd DD:hh:mm:ss"); try { File basicDir = new File(basicDirName); if(basicDir.isDirectory()) { File[] files = basicDir.listFiles(); for(int k=0;k<files.length;k++) { File indexFile = files[k]; long lastModify = indexFile.lastModified(); long mySize = indexFile.length(); String fileName = indexFile.getName(); int fileType = 0; //(1:文件 2:目录 3:图片) if(indexFile.isDirectory()) { fileType = 2; }else if(indexFile.isFile()) { if(fileName.endsWith(".jpg")||fileName.endsWith(".png")||fileName.endsWith(".jpeg")||fileName.endsWith(".gif")) { fileType = 3; }else { fileType = 1; } } VCFile vcFile = new VCFile(indexFile.getPath(), indexFile.getPath(), mySize, lastModify, fileName, fileType); listFile.add(vcFile); } } }catch(Exception e1) { e1.printStackTrace(); } return listFile; }
[{"filePAth":"/home/luo/Figure_1-15.png","fileSize":626246,"lastModify":1551423371000,"fileName":"Figure_1-15.png","fileType":3,"path":"/home/luo/Figure_1-15.png"},{"filePAth":"/home/luo/.bash_logout","fileSize":220,"lastModify":1532436306000,"fileName":".bash_logout","fileType":1,"path":"/home/luo/.bash_logout"},{"filePAth":"/home/luo/Figure_1-5.png","fileSize":959452,"lastModify":1551422561000,"fileName":"Figure_1-5.png","fileType":3,"path":"/home/luo/Figure_1-5.png"},{"filePAth":"/home/luo/Desktop","fileSize":4096,"lastModify":1573646590000,"fileName":"Desktop","fileType":2,"path":"/home/luo/Desktop"},{"filePAth":"/home/luo/.Xauthority","fileSize":124,"lastModify":1551057586000,"fileName":".Xauthority","fileType":1,"path":"/home/luo/.Xauthority"},{"filePAth":"/home/luo/.cmake","fileSize":4096,"lastModify":1543998690000,"fileName":".cmake","fileType":2,"path":"/home/luo/.cmake"},{"filePAth":"/home/luo/.keras","fileSize":4096,"lastModify":1532440244000,"fileName":".keras","fileType":2,"path":"/home/luo/.keras"},{"filePAth":"/home/luo/.vscode","fileSize":4096,"lastModify":1532438402000,"fileName":".vscode","fileType":2,"path":"/home/luo/.vscode"},{"filePAth":"/home/luo/.rpmdb","fileSize":4096,"lastModify":1560687645000,"fileName":".rpmdb","fileType":2,"path":"/home/luo/.rpmdb"},{"filePAth":"/home/luo/Untitled 2.xlsx","fileSize":4293,"lastModify":1533625693000,"fileName":"Untitled 2.xlsx","fileType":1,"path":"/home/luo/Untitled 2.xlsx"},{"filePAth":"/home/luo/.profile","fileSize":702,"lastModify":1536661683000,"fileName":".profile","fileType":1,"path":"/home/luo/.profile"},{"filePAth":"/home/luo/Figure_1-12.png","fileSize":504495,"lastModify":1551423186000,"fileName":"Figure_1-12.png","fileType":3,"path":"/home/luo/Figure_1-12.png"},{"filePAth":"/home/luo/.mplayer","fileSize":4096,"lastModify":1552101470000,"fileName":".mplayer","fileType":2,"path":"/home/luo/.mplayer"},{"filePAth":"/home/luo/baidunetdisk","fileSize":4096,"lastModify":1560687847000,"fileName":"baidunetdisk","fileType":2,"path":"/home/luo/baidunetdisk"},{"filePAth":"/home/luo/.designer","fileSize":4096,"lastModify":1545033251000,"fileName":".designer","fileType":2,"path":"/home/luo/.designer"},{"filePAth":"/home/luo/Figure_1-14.png","fileSize":922322,"lastModify":1551423314000,"fileName":"Figure_1-14.png","fileType":3,"path":"/home/luo/Figure_1-14.png"},{"filePAth":"/home/luo/.gconf","fileSize":4096,"lastModify":1551065291000,"fileName":".gconf","fileType":2,"path":"/home/luo/.gconf"},{"filePAth":"/home/luo/.sudo_as_admin_successful","fileSize":0,"lastModify":1532437491000,"fileName":".sudo_as_admin_successful","fileType":1,"path":"/home/luo/.sudo_as_admin_successful"},{"filePAth":"/home/luo/.mysql_history","fileSize":193182,"lastModify":1534670309000,"fileName":".mysql_history","fileType":1,"path":"/home/luo/.mysql_history"},{"filePAth":"/home/luo/Videos","fileSize":4096,"lastModify":1532437312000,"fileName":"Videos","fileType":2,"path":"/home/luo/Videos"},{"filePAth":"/home/luo/COCO201909","fileSize":4096,"lastModify":1568278473000,"fileName":"COCO201909","fileType":2,"path":"/home/luo/COCO201909"},{"filePAth":"/home/luo/Test1","fileSize":4096,"lastModify":1532763918000,"fileName":"Test1","fileType":2,"path":"/home/luo/Test1"},{"filePAth":"/home/luo/.jupyter","fileSize":4096,"lastModify":1534495287000,"fileName":".jupyter","fileType":2,"path":"/home/luo/.jupyter"},{"filePAth":"/home/luo/Figure_1-9.png","fileSize":1146895,"lastModify":1551422876000,"fileName":"Figure_1-9.png","fileType":3,"path":"/home/luo/Figure_1-9.png"},{"filePAth":"/home/luo/.dbus","fileSize":4096,"lastModify":1532438655000,"fileName":".dbus","fileType":2,"path":"/home/luo/.dbus"},{"filePAth":"/home/luo/Figure_1-4.png","fileSize":620477,"lastModify":1551422409000,"fileName":"Figure_1-4.png","fileType":3,"path":"/home/luo/Figure_1-4.png"},{"filePAth":"/home/luo/torch","fileSize":4096,"lastModify":1536653064000,"fileName":"torch","fileType":2,"path":"/home/luo/torch"},{"filePAth":"/home/luo/.tooling","fileSize":4096,"lastModify":1532588387000,"fileName":".tooling","fileType":2,"path":"/home/luo/.tooling"},{"filePAth":"/home/luo/Figure_1-1.png","fileSize":754620,"lastModify":1551421280000,"fileName":"Figure_1-1.png","fileType":3,"path":"/home/luo/Figure_1-1.png"},{"filePAth":"/home/luo/.eclipse","fileSize":4096,"lastModify":1542443880000,"fileName":".eclipse","fileType":2,"path":"/home/luo/.eclipse"},{"filePAth":"/home/luo/.labelmerc","fileSize":1373,"lastModify":1551176630000,"fileName":".labelmerc","fileType":1,"path":"/home/luo/.labelmerc"},{"filePAth":"/home/luo/.wget-hsts","fileSize":225,"lastModify":1570763208000,"fileName":".wget-hsts","fileType":1,"path":"/home/luo/.wget-hsts"},{"filePAth":"/home/luo/.gnupg","fileSize":4096,"lastModify":1566717348000,"fileName":".gnupg","fileType":2,"path":"/home/luo/.gnupg"},{"filePAth":"/home/luo/.xinputrc","fileSize":132,"lastModify":1532479885000,"fileName":".xinputrc","fileType":1,"path":"/home/luo/.xinputrc"},{"filePAth":"/home/luo/baidunetdiskdownload","fileSize":4096,"lastModify":1560687847000,"fileName":"baidunetdiskdownload","fileType":2,"path":"/home/luo/baidunetdiskdownload"},{"filePAth":"/home/luo/.gitconfig","fileSize":24,"lastModify":1536494339000,"fileName":".gitconfig","fileType":1,"path":"/home/luo/.gitconfig"},{"filePAth":"/home/luo/.xsession-errors","fileSize":1481,"lastModify":1551067843000,"fileName":".xsession-errors","fileType":1,"path":"/home/luo/.xsession-errors"},{"filePAth":"/home/luo/.byobu","fileSize":4096,"lastModify":1552101462000,"fileName":".byobu","fileType":2,"path":"/home/luo/.byobu"},{"filePAth":"/home/luo/.python_history","fileSize":4058,"lastModify":1568373928000,"fileName":".python_history","fileType":1,"path":"/home/luo/.python_history"},{"filePAth":"/home/luo/.dmrc","fileSize":25,"lastModify":1532437311000,"fileName":".dmrc","fileType":1,"path":"/home/luo/.dmrc"},{"filePAth":"/home/luo/Figure_1-6.png","fileSize":965854,"lastModify":1551422656000,"fileName":"Figure_1-6.png","fileType":3,"path":"/home/luo/Figure_1-6.png"},{"filePAth":"/home/luo/.ipython","fileSize":4096,"lastModify":1532482171000,"fileName":".ipython","fileType":2,"path":"/home/luo/.ipython"},{"filePAth":"/home/luo/.conda","fileSize":4096,"lastModify":1532438866000,"fileName":".conda","fileType":2,"path":"/home/luo/.conda"},{"filePAth":"/home/luo/Figure_1-2.png","fileSize":623281,"lastModify":1551421427000,"fileName":"Figure_1-2.png","fileType":3,"path":"/home/luo/Figure_1-2.png"},{"filePAth":"/home/luo/Figure_1-3.png","fileSize":1032853,"lastModify":1551421490000,"fileName":"Figure_1-3.png","fileType":3,"path":"/home/luo/Figure_1-3.png"},{"filePAth":"/home/luo/.ssh","fileSize":4096,"lastModify":1566717348000,"fileName":".ssh","fileType":2,"path":"/home/luo/.ssh"},{"filePAth":"/home/luo/.presage","fileSize":4096,"lastModify":1532479890000,"fileName":".presage","fileType":2,"path":"/home/luo/.presage"},{"filePAth":"/home/luo/.cache","fileSize":4096,"lastModify":1573644272000,"fileName":".cache","fileType":2,"path":"/home/luo/.cache"},{"filePAth":"/home/luo/.mozilla","fileSize":4096,"lastModify":1532475082000,"fileName":".mozilla","fileType":2,"path":"/home/luo/.mozilla"},{"filePAth":"/home/luo/Figure_1-7.png","fileSize":609727,"lastModify":1551422717000,"fileName":"Figure_1-7.png","fileType":3,"path":"/home/luo/Figure_1-7.png"},{"filePAth":"/home/luo/.oracle_jre_usage","fileSize":4096,"lastModify":1532474935000,"fileName":".oracle_jre_usage","fileType":2,"path":"/home/luo/.oracle_jre_usage"},{"filePAth":"/home/luo/Figure_1-11.png","fileSize":885926,"lastModify":1551423132000,"fileName":"Figure_1-11.png","fileType":3,"path":"/home/luo/Figure_1-11.png"},{"filePAth":"/home/luo/.compiz","fileSize":4096,"lastModify":1532440487000,"fileName":".compiz","fileType":2,"path":"/home/luo/.compiz"},{"filePAth":"/home/luo/.swt","fileSize":4096,"lastModify":1532588809000,"fileName":".swt","fileType":2,"path":"/home/luo/.swt"},{"filePAth":"/home/luo/Java","fileSize":4096,"lastModify":1532474614000,"fileName":"Java","fileType":2,"path":"/home/luo/Java"},{"filePAth":"/home/luo/.accelerate","fileSize":4096,"lastModify":1560687780000,"fileName":".accelerate","fileType":2,"path":"/home/luo/.accelerate"},{"filePAth":"/home/luo/.sts4","fileSize":4096,"lastModify":1573634853000,"fileName":".sts4","fileType":2,"path":"/home/luo/.sts4"},{"filePAth":"/home/luo/Figure_1-8.png","fileSize":387034,"lastModify":1551422796000,"fileName":"Figure_1-8.png","fileType":3,"path":"/home/luo/Figure_1-8.png"},{"filePAth":"/home/luo/.config","fileSize":4096,"lastModify":1573456573000,"fileName":".config","fileType":2,"path":"/home/luo/.config"},{"filePAth":"/home/luo/.bashrc","fileSize":3894,"lastModify":1536661683000,"fileName":".bashrc","fileType":1,"path":"/home/luo/.bashrc"},{"filePAth":"/home/luo/Downloads","fileSize":16384,"lastModify":1573615032000,"fileName":"Downloads","fileType":2,"path":"/home/luo/Downloads"},{"filePAth":"/home/luo/.nv","fileSize":4096,"lastModify":1536327839000,"fileName":".nv","fileType":2,"path":"/home/luo/.nv"},{"filePAth":"/home/luo/.bash_history","fileSize":33546,"lastModify":1573644684000,"fileName":".bash_history","fileType":1,"path":"/home/luo/.bash_history"},{"filePAth":"/home/luo/.local","fileSize":4096,"lastModify":1536654987000,"fileName":".local","fileType":2,"path":"/home/luo/.local"},{"filePAth":"/home/luo/Figure_1-13.png","fileSize":504495,"lastModify":1551423246000,"fileName":"Figure_1-13.png","fileType":3,"path":"/home/luo/Figure_1-13.png"},{"filePAth":"/home/luo/.gnome","fileSize":4096,"lastModify":1532476616000,"fileName":".gnome","fileType":2,"path":"/home/luo/.gnome"},{"filePAth":"/home/luo/.labelImgSettings.pkl","fileSize":1006,"lastModify":1560911870000,"fileName":".labelImgSettings.pkl","fileType":1,"path":"/home/luo/.labelImgSettings.pkl"},{"filePAth":"/home/luo/myspider0315","fileSize":4096,"lastModify":1552617918000,"fileName":"myspider0315","fileType":2,"path":"/home/luo/myspider0315"},{"filePAth":"/home/luo/.sogouinput","fileSize":4096,"lastModify":1532479906000,"fileName":".sogouinput","fileType":2,"path":"/home/luo/.sogouinput"},{"filePAth":"/home/luo/pytorch","fileSize":4096,"lastModify":1536495502000,"fileName":"pytorch","fileType":2,"path":"/home/luo/pytorch"},{"filePAth":"/home/luo/Pictures","fileSize":28672,"lastModify":1573461009000,"fileName":"Pictures","fileType":2,"path":"/home/luo/Pictures"},{"filePAth":"/home/luo/examples.desktop","fileSize":8980,"lastModify":1532436307000,"fileName":"examples.desktop","fileType":1,"path":"/home/luo/examples.desktop"},{"filePAth":"/home/luo/.viminfo","fileSize":19919,"lastModify":1573607459000,"fileName":".viminfo","fileType":1,"path":"/home/luo/.viminfo"},{"filePAth":"/home/luo/.pylint.d","fileSize":4096,"lastModify":1572308018000,"fileName":".pylint.d","fileType":2,"path":"/home/luo/.pylint.d"},{"filePAth":"/home/luo/.xsession-errors.old","fileSize":1234,"lastModify":1551057518000,"fileName":".xsession-errors.old","fileType":1,"path":"/home/luo/.xsession-errors.old"},{"filePAth":"/home/luo/.bashrc-anaconda3.bak","fileSize":3771,"lastModify":1532438187000,"fileName":".bashrc-anaconda3.bak","fileType":1,"path":"/home/luo/.bashrc-anaconda3.bak"},{"filePAth":"/home/luo/anaconda3","fileSize":4096,"lastModify":1532438187000,"fileName":"anaconda3","fileType":2,"path":"/home/luo/anaconda3"},{"filePAth":"/home/luo/Music","fileSize":4096,"lastModify":1532437312000,"fileName":"Music","fileType":2,"path":"/home/luo/Music"},{"filePAth":"/home/luo/.p2","fileSize":4096,"lastModify":1573646623000,"fileName":".p2","fileType":2,"path":"/home/luo/.p2"},{"filePAth":"/home/luo/Templates","fileSize":4096,"lastModify":1532437312000,"fileName":"Templates","fileType":2,"path":"/home/luo/Templates"},{"filePAth":"/home/luo/Documents","fileSize":4096,"lastModify":1573619579000,"fileName":"Documents","fileType":2,"path":"/home/luo/Documents"},{"filePAth":"/home/luo/Figure_1-16.png","fileSize":491925,"lastModify":1551423524000,"fileName":"Figure_1-16.png","fileType":3,"path":"/home/luo/Figure_1-16.png"},{"filePAth":"/home/luo/.thunderbird","fileSize":4096,"lastModify":1545216900000,"fileName":".thunderbird","fileType":2,"path":"/home/luo/.thunderbird"},{"filePAth":"/home/luo/Public","fileSize":4096,"lastModify":1532437312000,"fileName":"Public","fileType":2,"path":"/home/luo/Public"},{"filePAth":"/home/luo/TensorflowProject","fileSize":4096,"lastModify":1556950958000,"fileName":"TensorflowProject","fileType":2,"path":"/home/luo/TensorflowProject"},{"filePAth":"/home/luo/Figure_1-10.png","fileSize":1052482,"lastModify":1551422965000,"fileName":"Figure_1-10.png","fileType":3,"path":"/home/luo/Figure_1-10.png"},{"filePAth":"/home/luo/imgui.ini","fileSize":516,"lastModify":1532580109000,"fileName":"imgui.ini","fileType":1,"path":"/home/luo/imgui.ini"},{"filePAth":"/home/luo/.pki","fileSize":4096,"lastModify":1532476609000,"fileName":".pki","fileType":2,"path":"/home/luo/.pki"},{"filePAth":"/home/luo/Figure_1.png","fileSize":625748,"lastModify":1551421204000,"fileName":"Figure_1.png","fileType":3,"path":"/home/luo/Figure_1.png"},{"filePAth":"/home/luo/.ICEauthority","fileSize":55748,"lastModify":1573608205000,"fileName":".ICEauthority","fileType":1,"path":"/home/luo/.ICEauthority"},{"filePAth":"/home/luo/.ipynb_checkpoints","fileSize":4096,"lastModify":1546413002000,"fileName":".ipynb_checkpoints","fileType":2,"path":"/home/luo/.ipynb_checkpoints"},{"filePAth":"/home/luo/.gphoto","fileSize":4096,"lastModify":1538004226000,"fileName":".gphoto","fileType":2,"path":"/home/luo/.gphoto"},{"filePAth":"/home/luo/.m2","fileSize":4096,"lastModify":1573619622000,"fileName":".m2","fileType":2,"path":"/home/luo/.m2"}]