<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 26,  comments - 14,  trackbacks - 0
    殺毒軟件:
    殺毒軟件是每一臺電腦不可少的應(yīng)用軟件之一,現(xiàn)在我來研究 一下殺毒軟件的整個工作流程吧。。。首先要明確殺毒軟件的目的是什么,怎么樣才能實現(xiàn)這一目的。。。
    殺毒軟件是客戶在通過掃描自己的電腦里的每一個文件,然后與殺毒軟件服務(wù)器病毒庫里的病毒相比較,如果你電腦里有和服務(wù)器中文件相同的,殺毒軟件就視為是病毒,然后有用戶選擇是否要把掃描出來的文件刪除。。。。下面是我用Java語言來實現(xiàn)這個功能的。。。希望對大家有所感悟。現(xiàn)在說說我的具體實現(xiàn)的步驟吧。



    服務(wù)器代碼:

    package server;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.util.ArrayList;
    import java.util.List;

    import com.dr.bean.Virus;

     


    public class Server {
     


     public static List<Virus> virusList = new ArrayList<Virus>();
     public static void main(String[] args) throws IOException {
      ServerSocket server = null;
      //輸出肯定使用打印流
      PrintStream out = null;
      //服務(wù)器肯定也要接收數(shù)據(jù)
      BufferedReader buf = null;
      //實例化一個服務(wù)器的監(jiān)聽端
      server = new ServerSocket(8888);
      //可以用一種死循環(huán)的方式接收內(nèi)容
      System.out.println("---------服務(wù)器已經(jīng)啟動----------");
      Socket client = null;
      //初始化暗殺名單
      //List<Virus> virusList = getVirusList();
      while(true){
       //不斷接收內(nèi)容
       client = server.accept();
       //準備好向客戶端輸入內(nèi)容
       out = new PrintStream(client.getOutputStream());
       //而且客戶端要有輸入給服務(wù)器端
       buf = new BufferedReader(new InputStreamReader(client.getInputStream()));
       
       
       //接收客戶端發(fā)送過來的內(nèi)容
       String str = buf.readLine();
       System.out.println("server receive data is:"+str);
       String virus = "";
       if("getVirusList".equals(str)){//組成暗殺協(xié)議,返回客戶端
        for(Virus v :virusList){
         virus += v.getName()+":";
        }
        out.println(virus);
       }
       
       //進行收尾工作
       out.flush();
       out.close();
       buf.close();
       client.close();
      }
      
      
     }
     
     public static List<Virus> getVirusList(){
      
      Virus virus = null;
      
      virus = new Virus();
      virus.setName("QQ.exe");
      virusList.add(virus);
      
      virus = new Virus();
      virus.setName("Niu.exe");
      virusList.add(virus);
      
      virus = new Virus();
      virus.setName("Baidu.exe");
      virusList.add(virus);
      
      virus = new Virus();
      virus.setName("Jinshan.exe");
      virusList.add(virus);
      
      return virusList;
     }

     

    }

    執(zhí)行結(jié)果:
     
    客戶端代碼

    package com.dr.client;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.util.ArrayList;
    import java.util.List;

    import com.dr.bean.Virus;


    public class Client {

     private String str;
     private List<Virus> virusList = null;
        public Client(String str){
         this.str = str;
         virusList = new ArrayList<Virus>();
        }
     
     public List<Virus> send() throws UnknownHostException, IOException{
      Socket client = null;
      //接收服務(wù)器信息的輸入流
      BufferedReader buf = null;
      //向服務(wù)器發(fā)送信息的輸出流
      PrintStream out = null;
      //實例化一個套接字
      client = new Socket("localhost",8888);
      //從服務(wù)器接收信息
      buf = new BufferedReader(new InputStreamReader(client.getInputStream()));
      //向服務(wù)器打印信息
      out = new PrintStream(client.getOutputStream());
      
      
      //打印出去
      out.println(this.str);
      //接收進來QQ.exe:baidu.exe:niu.exe
      String msg = buf.readLine();
      System.out.println(msg);
      String[] msgArray = msg.split(":");
      for(int i=0;i<msgArray.length;i++){
       Virus v = new Virus();
       v.setName(msgArray[i]);
       virusList.add(v);
       System.out.println(msgArray[i]);
      }
      

      buf.close();
      out.flush();
      out.close();
      client.close();
      
      return virusList;
     }
    }

     

    文件掃描過程代碼類:::

    package com.dr.client;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.util.ArrayList;
    import java.util.List;

    import com.dr.bean.Virus;


    public class Client {

     private String str;
     private List<Virus> virusList = null;
        public Client(String str){
         this.str = str;
         virusList = new ArrayList<Virus>();
        }
     
     public List<Virus> send() throws UnknownHostException, IOException{
      Socket client = null;
      //接收服務(wù)器信息的輸入流
      BufferedReader buf = null;
      //向服務(wù)器發(fā)送信息的輸出流
      PrintStream out = null;
      //實例化一個套接字
      client = new Socket("localhost",8888);
      //從服務(wù)器接收信息
      buf = new BufferedReader(new InputStreamReader(client.getInputStream()));
      //向服務(wù)器打印信息
      out = new PrintStream(client.getOutputStream());
      
      
      //打印出去
      out.println(this.str);
      //接收進來QQ.exe:baidu.exe:niu.exe
      String msg = buf.readLine();
      System.out.println(msg);
      String[] msgArray = msg.split(":");
      for(int i=0;i<msgArray.length;i++){
       Virus v = new Virus();
       v.setName(msgArray[i]);
       virusList.add(v);
       System.out.println(msgArray[i]);
      }
      

      buf.close();
      out.flush();
      out.close();
      client.close();
      
      return virusList;
     }
    }





    KillVirusUI代碼:


    package com.dr.ui;

    import java.io.File;
    import java.util.ArrayList;
    import java.util.List;

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.graphics.Color;
    import org.eclipse.swt.graphics.Font;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.DirectoryDialog;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.ProgressBar;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;

    import com.dr.file.FileList;

    public class KillVirusUI {

     public static String filePath = "";
     public static List<String> virusFilePath = new ArrayList<String>();
     public static void main(String args[]) {
      Display display = new Display();
      final Shell shell = new Shell(display, SWT.SHELL_TRIM);
      shell.setBounds(2, 2, 1200, 600);
      //shell.setMaximized(true);// 全屏顯示
      shell.setText("殺毒軟件簡單版");
      /**
       * 設(shè)置執(zhí)行按鈕
       */
      final Button btnOk = new Button(shell, SWT.PUSH);
      btnOk.setBounds(20, 25, 70, 25);
      btnOk.setText("掃描殺毒");
      final Button btnOk1 = new Button(shell, SWT.PUSH);
      btnOk1.setBounds(120, 25, 70, 25);
      btnOk1.setText("刪除病毒");

       Color color = new Color(Display.getCurrent(), 100, 180, 10);// 聲明顏色對象
       Color color1 = new Color(Display.getCurrent(), 100, 220, 240);// 聲明顏色對象
      final Text text = new Text(shell, SWT.MULTI | SWT.BORDER);
      text.setBounds(10, 270, 1200, 400);
      text.setBackground(color1);
      final Text text1 = new Text(shell, SWT.MULTI | SWT.BORDER);
      text1.setBounds(10, 150, 1200, 50);
      text1.setBackground(color1);
      
      final ProgressBar progressBar = new ProgressBar(shell, SWT.HORIZONTAL);
      GridData data = new GridData();
      data.horizontalSpan = 2;
      data.grabExcessHorizontalSpace = true;
      progressBar.setLayoutData(data);
      progressBar.setMaximum(100);// 設(shè)置最大值
      progressBar.setMinimum(0);// 設(shè)置最小值
      /**
       * 注冊點擊事件,循環(huán)顯示數(shù)據(jù)
       */
      
      Label labe=new Label(shell,SWT.NULL);
         labe.setBounds(800,25, 120,75); // 設(shè)置按鈕位置
         labe.setFont(new Font(display,"宋體",20,SWT.BOLD));
       
       
         labe.setBackground( color);
      labe.setText("    "+"360"+"\n"+"網(wǎng)絡(luò)保鏢");
      ;
      btnOk.addSelectionListener(new SelectionAdapter() {//Button監(jiān)聽事件
       public void widgetSelected(SelectionEvent e) {
        FileList f = new FileList();
        DirectoryDialog dlg = new DirectoryDialog(shell);
        dlg.setText("目錄"); // 設(shè)置窗口標題
        dlg.setMessage("請選擇一個目錄:"); // 設(shè)置提示文字
        dlg.setFilterPath("/root"); // 設(shè)置初始目錄
        String dir = dlg.open(); // 打開對話框并返回一個包含所選目錄路徑的字符串
        
        //File f=new File(dlg.open());
           f.setStr(dir);
        
        if (f != null)
         System.out.println(f); // 比如選擇“我的文檔”,則會打印“D:\My Documents”
        
        
        Thread t = new Thread(f);
        t.setDaemon(true);
        t.start();
        t.yield();
        
        for(int i=0;i<100;i++){
         text.append(filePath+"\n"); 
         progressBar.setBounds(10, 80, 1200, 20);
         progressBar.setSelection(progressBar.getSelection()+1);//顯示一條數(shù)據(jù),滾動條進度加1
         try {
          Thread.sleep(1000);
         } catch (InterruptedException e1) {
          e1.printStackTrace();
         }
        }
        
        if(virusFilePath.size()!=0){
         text.setText("");
         for(String str : virusFilePath){
          text1.append("很悲劇:你的電腦里發(fā)現(xiàn)病毒:"+str+"\n");
         }
        }
        else{
         text1.setText("恭喜你,沒有發(fā)現(xiàn)病毒!");
        }
        t.interrupt();
        
       }
      
      });
      
      
      btnOk1.addSelectionListener(new SelectionAdapter() {//Button監(jiān)聽事件
       public void widgetSelected(SelectionEvent e) {
        FileList q = new FileList();
        Thread t = new Thread(q);
        t.setDaemon(true);
        t.start();
        for(int i=0;i<100;i++){
         text.append(filePath+"\n");
         progressBar.setBounds(10, 105, 1200, 20);
         progressBar.setSelection(progressBar.getSelection()+1);//顯示一條數(shù)據(jù),滾動條進度加1
         try {
          Thread.sleep(100);
         } catch (InterruptedException e1) {
          e1.printStackTrace();
         }
        }
        
        if(virusFilePath.size()!=0){
         text.setText("");
         for(String str : virusFilePath){
          //text1.append("發(fā)現(xiàn)病毒:"+str+"\n");
          
             File f1=new File("f.filePath");
          f1.delete();
          text1.append("恭喜你已經(jīng)成功清理了電腦里的病毒:"+str+"\n");
         }
        }
        else{
         text1.setText("祝賀你不用為電腦安危考慮了!");
        }
       }
       });
      
      
      shell.open();
      while (!shell.isDisposed()) {
       if (!display.readAndDispatch())
        display.sleep();
      }
      display.dispose();
     }
    }

    執(zhí)行結(jié)果:

     
    首先要啟動服務(wù)器,殺毒軟件才能夠正常的工作。。。。。。。


    病毒類:

    package com.dr.bean;


    public class Virus{

     private String name;
     public String getName() {
      return name;
     }
     public void setName(String name) {
      this.name = name;
     }
    }


    posted on 2010-11-23 13:43 龍ぜ殘劍 閱讀(2113) 評論(2)  編輯  收藏

    FeedBack:
    # re: 360 殺毒軟件之簡化版
    2010-11-23 16:25 | 龍ぜ殘劍
    過獎了@comanswer
      回復(fù)  更多評論
      
    # re: 360 殺毒軟件之簡化版[未登錄]
    2010-11-23 16:32 | abc
    哎,是夠簡化的,就是簡化的CS。殺毒可不是這么簡單的一回事。  回復(fù)  更多評論
      

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    <2010年11月>
    31123456
    78910111213
    14151617181920
    21222324252627
    2829301234
    567891011

    常用鏈接

    留言簿

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲愉拍99热成人精品热久久| 无码AV片在线观看免费| 亚洲AV无码精品国产成人| 无遮挡国产高潮视频免费观看| 亚美影视免费在线观看| 亚洲美女视频免费| 亚洲色欲久久久久综合网| 亚洲专区一路线二| 国产免费人成视频在线播放播 | 亚洲av日韩av不卡在线观看| 亚洲一区在线免费观看| 亚洲免费电影网站| 超清首页国产亚洲丝袜| 亚洲Av无码国产一区二区| 韩国二级毛片免费播放| 亚洲AV无码成人精品区蜜桃| 国产精品亚洲片在线花蝴蝶| 曰曰鲁夜夜免费播放视频 | 国产免费观看网站| 亚洲资源最新版在线观看| 亚洲免费在线播放| 亚洲成av人片在线看片| 少妇无码一区二区三区免费| 亚洲综合一区二区精品久久| 免费成人高清在线视频| 国产片免费福利片永久| 国产亚洲精品bv在线观看| 69式互添免费视频| 亚洲AV无码XXX麻豆艾秋| 久久精品国产精品亚洲人人| 一区二区三区观看免费中文视频在线播放 | 国产黄色一级毛片亚洲黄片大全| 国产尤物在线视精品在亚洲| 久久精品亚洲男人的天堂| 99在线观看视频免费| 亚洲AV无码久久精品成人| 成年在线观看网站免费| 亚洲人成小说网站色| 亚洲乱码日产精品a级毛片久久 | 亚洲伊人久久大香线蕉影院| 亚洲电影免费观看|