How to Write a virus scanning and removal software in Java

Source: Internet
Author: User

How to Write a virus scanning and removal software in Java:
Topic: idea; uses a set of links, an installed file, an installed hidden file, and then compares the two containers. There may be simpler ideas. You can post them for reference... Package iotest; import java. Io. *; import java. util. *; // Delete the hidden Virus
Public class virustest {public static Sequence List <File> list1 = new sequence list <File> (); public static Sequence List <File> list2 = new sequence list <File> (); public static void main (string [] ARGs) {file F = new file ("D:/DIR"); List (f); // recursively generates all files and folders, at the same time, all the files are put into the list1 set, and the hidden files are put into the list2 set.
// Note that the iterator cannot compare two list sets one by one, so the following for loop (INT I = 0; I <list1.size (); I ++) is available) {for (Int J = 0; j <list2.size (); j ++) {If (list1.get (I ). getname (). contains (list2.get (j ). getname () {// system. out. println (list1.get (I); If (! List1.get (I). getname (). Equals (list2.get (j). getname () & list1.get (I). getname (). endswith ("EXE ")){
// System. out. println (list1.get (I); list1.get (I ). delete () ;}// end if }// end for} // open all the files and folders in the file in sequence, recursive public static void list (file F) {file [] fn = f. listfiles (); For (INT I = 0; I <fn. length; I ++) {// system. out. println (FN [I]. getname (); list1.push (FN [I]); // save all the files to set 1
If (FN [I]. isdirectory ()){
List (FN [I]);} If (FN [I]. ishidden () {list2.push (FN [I]); // Save the hidden file to the Set 2 }}}}}

Related Article

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.