2

私はJavaネットワーキングプロジェクトに取り組んでいます。私のモジュールの1つは、特定のフォルダーまたはファイルが共有されているかどうか、および共有されているかどうかを知る必要があります。ネットワーク上の全員と共有するか、Windows にオプションがあるため、特定の人とのみ共有するかを意味します。これもファイルの属性である必要がありますが、これを確認する方法が見つかりません。

4

1 に答える 1

1

You can use file's exists method to determine if the directory is sharing folder.

Try this:

public static void main(String[] args) throws UnknownHostException {
    InetAddress addr;
    addr = InetAddress.getLocalHost();
    String hostname = addr.getHostName();

    if (hostname != null) {
        File f = new File("\\\\" + hostname + "\\temp");            
        if (f.exists()) {
            System.out.println("directory temp is shared");
        }           

    }

}
于 2013-10-24T08:13:16.617 に答える