0

I'm currently building a Java app that could detect USB drive, and can identify the difference between a personal USB drive and an unauthorized USB drive by using vendor serial number, my goal is to whitelist the identified USB drive and so only the unauthorized vendor serial number is shown.

Preferably I'd like to add a feature where I could add the more authorized USB drive as a list.

SRC code:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package serialnumber;

import java.nio.file.FileStore;
import java.nio.file.FileSystems;

/**
 *
 * @author Verdatabo
 */
public class SerialNumber {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        StringBuilder sb=new StringBuilder();
        String saved_vsn ="Windows (C:)         vsn:-1024236825" +"Can-a-bees (D:)      vsn:-2142019920";

        // while(true)
        //{
        for (FileStore store : FileSystems.getDefault().getFileStores())
        {
            sb.append(String.format("%-20s vsn:%s\n", store, store.getAttribute("volume:vsn")));



       //     if (!saved_vsn.equals(sb.append))

        //     {
                // System.out.println("SKIP");
         //    }

            System.out.println(sb.toString());
        }
        //}
    }

}

Output:

Windows (C:)         vsn:-1024236825

Windows (C:)         vsn:-1024236825
Can-a-bees (D:)      vsn:-2142019920

Windows (C:)         vsn:-1024236825
Can-a-bees (D:)      vsn:-2142019920
Fuscus (E:)          vsn:1719839436

Disconnected from the target VM, address: '127.0.0.1:17429', transport: 'socket'

Process finished with exit code 0
leonheess
  • 16,068
  • 14
  • 77
  • 112
  • 1
    Welcome to SO. Please have a look at [ask] and then actually _ask_ a question. – Thomas Sep 21 '20 at 08:58
  • It seems that your code is working fine. What part of it exactly is unclear to you? – Hulk Sep 21 '20 at 09:04
  • 1
    What, exactly, is your question? – NomadMaker Sep 21 '20 at 09:12
  • Yah my code is working fine it does show the output but im trying to make the code exclude Windows (C:) vsn:-1024236825 Can-a-bees (D:) vsn:-2142019920 , but i have no way making it work , because (!saved_vsn.equals(sb.append)) is not responding correctly. – verdatabo Sep 22 '20 at 03:08

0 Answers0