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 }}}}}