Home WeChat Applet Mini Program Development Share a small program to clean up garbage in memory cards and USB flash drives

Share a small program to clean up garbage in memory cards and USB flash drives

May 06, 2017 am 11:04 AM

There is a scenario where the phone’s memory card space is used up, but I don’t know which file is taking up too much. It’s too troublesome to find each folder, so I developed a small program to store all the files on the phone (including Files under all subfolders under the path) are sorted so that you can find out which file takes up too much memory.

The usage example is as follows, use JAVA to run Sort

1, and enter the path of the files you want to sort. For example, the example is to process the files under H:\ and the files under all its subfolders. Sort

2. Enter the latest size that needs to be sorted and displayed. For example, the example is to sort files above 10M in size

3. Sort from large to small and press

File path\file name-------Size KB--------Creation date is displayed (yyyyMMdd)

format is displayed.

This way you can delete files that are too large and clear up space

D:\hjbsSorft\work\20140207\SortSize\bin>java com.he.jinbin.Sort
Enter the address of the file to be sorted: H:\
Enter the size of the file to be sorted (unit M): 10
Running, please wait...
Sort files from large to small as:
H:\.android_secure\com.sg.android.fish-1.asec-------36224000 KB--------20130525
H:\BaiduMap\vmp\h\quanguogailue.dat -------27616013 KB--------20130512
H:\Download\RedGame_Android_2017-2013-11-06_18-54-27-CI-20.apk------- 26563096 KB--------20131111
H:\ugame\ugameSDK\downloads\6F9757F4442DD99FC89FA387C80405D2.apk-------26305964KB--------20131025
H:\Download \com.tencent.mobileqq_60.apk-------25417880 KB--------20130714
H:\Android\data\com.android.gallery3d\cache\imgcache.0--- ----22070789 KB--------20140210
H:\book\2014\ Different World Lingwu Tianxia\ Different World Lingwu Tianxia.txt-------20279247 KB----- ---20131114
H:\book\In-depth java virtual machine.pdf-------19936351 KB--------20130303
H:\book\2014\Guantu\Guantu. txt-------19668417 KB--------20130907
H:\book\Taoist Priests in Jin Yong's World.txt-------19004109 KB------- -20130102
H:\wandoujia\patch\快播_1390061188726.patch-------18649129 KB--------20140119
H:\BaiduMap\vmp\h\guangzhou_257. dat-------16645639 KB--------20140120
H:\book\War Emperor.txt-------15588332 KB--------20121215
H:\Download\com.tencent.mobileqq_52.apk-------15128435 KB--------20130521
H:\book\2014\Super Farmer\Super Farmer.txt- ------13913630 KB--------20130807
H:\book\2014\Tang Yin in Another World\Tang Yin in Another World.txt-------13328290 KB--- -----20130726
H:\book\2014\Doomsday Cockroach\Doomsday Cockroach.txt-------13177834 KB--------20131129
H:\book\2014 \Yi Jin Jing\Yi Jin Jing.txt-------12995888 KB--------20130715
H:\book\2014\The Red Alert of the Anti-Japanese War\The Red Alert of the Anti-Japanese War.txt- ------12828979 KB--------20130928
H:\book\new\道.txt-------12445787 KB--------20130326
H:\book\2014\1895 Gold Rush Country\1895 Gold Rush Country.txt-------12391071 KB--------20140104
H:\book\2014\Quan Chen\Quan Chen.txt -------11949796 KB--------20130726
H:\install\360weishi_167.apk-------11342128 KB--------20131009
H:\book\2013.9.19\Baiduditu.txt-------10776149 KB--------20130103
H:\install\baiduditu.apk------- 10685159 KB--------20130511
H:\DBOP\Resources\cfg\db.cfg-------10647552 KB--------20130520

The disadvantage of Windows is that it cannot display the size of the folder.

Only two categories,

package com.he.jinbin;import java.util.Date;/**
 * 用于排序逻辑实体类
 * 
 * @author 何锦彬    QQ 277803242
 * */public class FileItem implements Comparable {    private String fileName;    private long size;    private Date creatTime;    public FileItem(String fileName, long size, Date creaDate) {        // TODO Auto-generated constructor stub
        this.fileName = fileName;        this.size = size;        this.creatTime = creaDate;
    }    public String getFileName() {        return fileName;
    }    public void setFileName(String fileName) {        this.fileName = fileName;
    }    public long getSize() {        return size;
    }    public void setSize(long size) {        this.size = size;
    }    public Date getCreatTime() {        return creatTime;
    }    public void setCreatTime(Date creatTime) {        this.creatTime = creatTime;
    }

    @Override    public int compareTo(Object o) {        if (this.size > ((FileItem) o).getSize())            return 1;        return -1;
    }

}
Copy after login
package com.he.jinbin;import java.io.BufferedInputStream;import java.io.BufferedReader;import java.io.File;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Collections;import java.util.Date;import java.util.List;/**
 * 用于排序逻辑主类
 * 
 * @author 何锦彬    QQ 277803242
 * */public class Sort {    public static List<FileItem> fileItems = new ArrayList<FileItem>();    public static FileItem maxFileItem;    public final static long M_1 = 1024 * 1024;    public static long temp = M_1; // 默认大于1M的文件

    public static void addFileItem(File file) {
        File[] fileList = file.listFiles();        for (int i = 0; i < fileList.length; i++) {
            file = fileList[i];            if (file.isDirectory()) {
                addFileItem(file);
            } else {                if (file.length() > temp) {
                    fileItems.add(new FileItem(file.getPath(), file.length(),                            new Date(file.lastModified())));
                }

            }
        }

    }    public static void main(String[] args) throws IOException {
        String filePath = null;
        System.out.print("输入需要排序文件地址:");
        BufferedReader inRd = new BufferedReader(new InputStreamReader(
                System.in));
        filePath = inRd.readLine();
        System.out.print("输入需要排序文件大小(单位M):");
        inRd = new BufferedReader(new InputStreamReader(System.in));
        temp = Long.parseLong(inRd.readLine())*M_1;
        inRd.close();
        System.out.println("运行中,请稍等...");
        File file = new File(filePath);
        addFileItem(file);
        SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
        Collections.sort(fileItems);
        System.out.println("从大到小文件排序为:");        for (int i = fileItems.size() - 1; i >= 0; i--) {
            FileItem item = fileItems.get(i);
            System.out.println(item.getFileName() + "-------" + item.getSize()                    + " KB" + "--------" + fmt.format(item.getCreatTime()));
        }

    }
}
Copy after login

Although simple, my personal opinion is that programs are just tools. A good program is a program that brings convenience to life. It is not for showing off technology, just for practicality

【Related recommendations】

1. WeChat mini program source code download

2. WeChat mini program demo: imitation mall

The above is the detailed content of Share a small program to clean up garbage in memory cards and USB flash drives. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to clear memory on OPPO phones 'Understand in seconds: How to release memory on OPPO phones' How to clear memory on OPPO phones 'Understand in seconds: How to release memory on OPPO phones' Feb 07, 2024 pm 05:12 PM

Introduction: After using your mobile phone for a long time, there will be a large number of cache files, expired files, uninstallation residues, and installation package residues. Therefore, it is necessary to clean the mobile phone memory from time to time. Let’s take OPPO mobile phone as an example to illustrate. Tool: OPPOr9s mobile phone Method 1. Open [File Management] 2. Click [Clean] 3. Click the green [Clean] button Method 2 1. Open [Mobile Manager] 2. Click [Clean Acceleration] 3. Click [Clean] WeChat Cleaner 1. Open WeChat, click [Me] 2. Click [Settings] 3. Click [General] 4. Click [Clean WeChat Storage] 5. Click [Clean WeChat Storage] QQ Cleaner 1. Open QQ on your phone , click [Settings] 2. Click [Space Cleanup] 3. Click [Mobile QQ Storage Space]

How to clear memory on Xiaomi Mi 14? How to clear memory on Xiaomi Mi 14? Mar 18, 2024 am 10:31 AM

As the usage time increases, the memory of Xiaomi Mi 14 may be occupied by some unnecessary programs, causing the phone to run slower. To ensure that your phone always runs smoothly, it is crucial to clean the memory regularly. Below, we will introduce how to clean the memory of Xiaomi 14 to improve the performance and response speed of the phone. First, you can view the currently running applications by opening &quot;Application Management&quot; in the phone settings. Find the apps you don't need or rarely use and close or uninstall them to free up memory space. Secondly, use the system’s own “cleanup tool” to clean up the memory. This tool can help you quickly clean up cache files, temporary files and other junk files to free up memory space. In addition, you can also use Xiaomi Mi 14 to

How to clean the memory of oppo mobile phone 'Recommended operation method to clean the memory of mobile phone' How to clean the memory of oppo mobile phone 'Recommended operation method to clean the memory of mobile phone' Feb 06, 2024 pm 09:03 PM

Many people say that OPPO phones are very laggy after being used for a long time. In fact, it is because you don’t know how to clean up the garbage. What Wang Yao said today is to teach you how to clean up the garbage on OPPO phones. Let’s take a look below. 1. Basic cleaning There is a function in Mobile Phone Manager called "Clean Storage Space". Many people who use OPPO mobile phones are using this function to clean up garbage. In fact, this junk cleaning function is very practical and can easily clean most of the junk on your phone with one click. Therefore, this method of cleaning up garbage is very worthy of everyone’s use and should not be discarded easily. How to use: Mobile Phone Manager - Clean up storage space 2. Turn off WeChat automatic download. WeChat’s automatic download function will automatically cache videos, files and images in WeChat and Moments.

Simple method to clear memory in iPhone 8 Simple method to clear memory in iPhone 8 Mar 28, 2024 pm 02:39 PM

1. Click to open [Settings] on the desktop of the iPhone 8 phone. 2. Click [General]. 3. Click to enter [iPhone Storage Space]. 4. Click to enter infrequently used applications and click [Delete App] to clean them. Click [Delete App] again to complete.

PHP permission management and user role setting in mini program development PHP permission management and user role setting in mini program development Jul 04, 2023 pm 04:48 PM

PHP permission management and user role setting in mini program development. With the popularity of mini programs and the expansion of their application scope, users have put forward higher requirements for the functions and security of mini programs. Among them, permission management and user role setting are An important part of ensuring the security of mini programs. Using PHP for permission management and user role setting in mini programs can effectively protect user data and privacy. The following will introduce how to implement this function. 1. Implementation of Permission Management Permission management refers to granting different operating permissions based on the user's identity and role. in small

PHP page jump and routing management in mini program development PHP page jump and routing management in mini program development Jul 04, 2023 pm 01:15 PM

PHP's page jump and routing management in mini program development With the rapid development of mini programs, more and more developers are beginning to combine PHP with mini program development. In the development of small programs, page jump and routing management are very important parts, which can help developers achieve switching and navigation operations between pages. As a commonly used server-side programming language, PHP can interact well with mini programs and transfer data. Let’s take a detailed look at PHP’s page jump and routing management in mini programs. 1. Page jump base

How to implement small program development and publishing in uniapp How to implement small program development and publishing in uniapp Oct 20, 2023 am 11:33 AM

How to develop and publish mini programs in uni-app With the development of mobile Internet, mini programs have become an important direction in mobile application development. As a cross-platform development framework, uni-app can support the development of multiple small program platforms at the same time, such as WeChat, Alipay, Baidu, etc. The following will introduce in detail how to use uni-app to develop and publish small programs, and provide some specific code examples. 1. Preparation before developing small programs. Before starting to use uni-app to develop small programs, you need to do some preparations.

PHP security protection and attack prevention in mini program development PHP security protection and attack prevention in mini program development Jul 07, 2023 am 08:55 AM

PHP security protection and attack prevention in mini program development With the rapid development of the mobile Internet, mini programs have become an important part of people's lives. As a powerful and flexible back-end development language, PHP is also widely used in the development of small programs. However, security issues have always been an aspect that needs attention in program development. This article will focus on PHP security protection and attack prevention in small program development, and provide some code examples. XSS (Cross-site Scripting Attack) Prevention XSS attack refers to hackers injecting malicious scripts into web pages

See all articles