Folder rating Save file

Source: Internet
Author: User

When uploading files, there may be a lot of files, we know that when you put all the files in the same directory, open the directory is very slow

This also shows that the efficiency of finding files is reduced

We put the files in different directories, so as to improve the efficiency of file search

Folder hierarchy idea

Create a two-level directory with a 16-in-one naming folder so you can put files in 16*16=256 folders

1String str= "Lkjhgfds.jpg";//file name2         intA=str.hashcode ();//the hash value of the file name3         intB=a & 0xf;//4 digits after taking4 System.out.println (b);5String bin1=integer.tohexstring (b);//convert to 16 binary6System.out.println (bin1);//bin can be the first level directory name7         8         9         intC= (a>>4) & 0xf;//take last four bits front four bitsTen System.out.println (c); OneString bin2=integer.tohexstring (c);//convert to 16 binary ASystem.out.println (BIN2);//bin2 can be used as a second-level directory name
1 //make up a saved directory2savepath=path+ "/" +Savepath;3                     //determine if a directory exists4File f =NewFile (savepath);5                     if(!f.exists ()) {6                         //Create a directory7 f.mkdirs ();8}

Folder rating Save file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.