Java-implemented simple file management system

Source: Internet
Author: User

Design a file management solution to simulate a simple file management system. The directory structure must be a tree structure. The directory can be a directory or a file. Through this experiment, students can deeply understand the concept of the file system, the basic operations involved, and the main data structure during implementation.

 


Design Content

Design a file management solution to simulate a simple file management system. The directory structure must be a tree structure. The directory can be a directory or a file. In addition, the file management system can perform the following basic operations on file management:

  • Change directory: Format: CD <
    Directory Name>

  • Display Directory: Format: dir [<
    Directory Name>]

  • Create directory: Format: MD <
    Directory Name>

  • Delete Directory: Format: RD <
    Directory Name>

  • New File: Format: Edit <
    File Name>

  • Delete file: Format: del <
    File Name>

  • Exit File System: Exit

Outline Design

Class command

: This class is used to operate various commands on files
;

Core code for implementing the Program
;

 

Class mainframe


: This class is used to display the interface and provide the user with an interactive user interface.

 

Class expandlistener

: This class is used to listen to users' operations on the tree.
;

And find the path of the sub-file under the root directory of each file.

Class filemouselistener


: This class is used to listen to users' mouse operations

;


Select the root directory file with the mouse

 

Class filetreecellrenderer


: This class is used to set the icon of a file on the interface.

4.


Detailed Design

4.1


Main Algorithm Description

Class command

:

Public String [] listdisks ()
Show all drive letters in the system

Public String [] separate (string operation)
It mainly solves the problem that folders or files contain spaces.

Public void operate (string operation)
Operation
Perform corresponding operations

Public String getpath ()
Obtain the current directory

Public String [] listall (string path)
Obtain path
File under

Public String [] listdirectory (string path)

Public Boolean isrightpath (string path)
Determine whether the path is correct

Public void Cd (string path, string file)
CD
Operation; CD <
Directory Name>
Function:
Go to the next directory

Public void Dir (string path)
Perform dir
Operation; dir [<
Directory Name>]
Function:
Show all files in the directory

Public void MD (string directory)
Conduct MD
Operation; MD <
Directory Name>
Function:
Create a new directory
Public void RD (string directory)
Perform Rd
Operation; rd <
Directory Name>
Function:
Delete directory
Public void edit (string file)
Edit
Operation: Edit <
File Name>
Function:
Create a file

Public void del (string file)
Del
Operation; del <
File Name>
Function:
Delete an object

Public void exit ()
Exit
Operation;
Function:
Exit File System

Program Interface Design


 


 

Source code download: has been released to csdn resources;

Or in http://www.80hou.org.cn/bbs/viewthread.php? Tid = 32 & extra = download

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.