1 import jcifs.netbios.NbtAddress; 2 import jcifs.smb.SmbFile; 3 import java.util.Date ; 4 5 public class GetType { 6 7 static final String [] types = { "TYPE_FILESYSTEM", "TYPE_WORKGROUP", 8 "TYPE_SERVER", "TYPE_SHARE", "TYPE_NAMED_PIPE", "TYPE_PRINTER", "TYPE_COMM" }; 9 10 public static void main( String [] argv ) throws Exception { 11 12 SmbFile file = new SmbFile( argv[0] ); 13 int type; 14 15 switch( file.getType() ) { 16 case SmbFile.TYPE_FILESYSTEM: 17 type = 0; 18 break; 19 case SmbFile.TYPE_WORKGROUP: 20 type = 1; 21 break; 22 case SmbFile.TYPE_SERVER: 23 type = 2; 24 break; 25 case SmbFile.TYPE_SHARE: 26 type = 3; 27 break; 28 case SmbFile.TYPE_NAMED_PIPE: 29 type = 4; 30 break; 31 case SmbFile.TYPE_PRINTER: 32 type = 5; 33 break; 34 case SmbFile.TYPE_COMM: 35 type = 6; 36 break; 37 default: 38 throw new RuntimeException ( "Unknown service type: " + file.getType() ); 39 } 40 System.out.println( types[type] ); 41 System.out.println(); 42 43 long t1 = System.currentTimeMillis(); 44 String [] files = file.list(); 45 long t2 = System.currentTimeMillis() - t1; 46 47 for( int i = 0; i < files.length; i++ ) { 48 System.out.print( " " + files[i] ); 49 } 50 System.out.println(); 51 System.out.println( files.length + " files in " + t2 + "ms" ); 52 } 53 } 54
| Popular Tags
|