本文整理匯總了Java中jcifs.smb.SmbFile.listFiles方法的典型用法代碼示例。如果您正苦於以下問題:Java SmbFile.listFiles方法的具體用法?Java SmbFile.listFiles怎麽用?Java SmbFile.listFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jcifs.smb.SmbFile
的用法示例。
在下文中一共展示了SmbFile.listFiles方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performListing
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
private Set<SmbFile> performListing(final SmbFile directory2, final boolean recurseSubdirectories) throws SmbException {
if (!directory2.canRead() || !directory2.canWrite()) {
throw new IllegalStateException("Directory '" + directory2 + "' does not have sufficient permissions (i.e., not writable and readable)");
}
final Set<SmbFile> queue = new HashSet<SmbFile>();
if (!directory2.exists()) {
return queue;
}
final SmbFile[] children = directory2.listFiles();
if (children == null) {
return queue;
}
for (final SmbFile child : children) {
if (child.isDirectory()) {
if (recurseSubdirectories) {
queue.addAll(performListing(child, recurseSubdirectories));
}
} else {
queue.add(child);
}
}
return queue;
}
示例2: fsList
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
@Override
public List<EncFSFileInfo> fsList(String path) throws IOException {
System.out.println("*** fsList "+path+" => "+getAbsolutePath(path));
String pathToList = getAbsolutePath(path);
if (!pathToList.endsWith("/")) pathToList+="/";
SmbFile currentFolder = new SmbFile(pathToList, authentication);
SmbFile[] files = currentFolder.listFiles();
List<EncFSFileInfo> fList = new LinkedList<EncFSFileInfo>();
for(int a = 0; a < files.length; a++)
{
EncFSFileInfo encFSFileInfo = SmbFile2EncFSFileInfo(files[a]);
fList.add(encFSFileInfo);
}
return fList;
}
示例3: traverse
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
void traverse( SmbFile f, int depth ) throws MalformedURLException, IOException {
if( depth == 0 ) {
return;
}
SmbFile[] l = f.listFiles();
for(int i = 0; l != null && i < l.length; i++ ) {
try {
for( int j = maxDepth - depth; j > 0; j-- ) {
System.out.print( " " );
}
System.out.println( l[i] + " " + l[i].exists() );
if( l[i].isDirectory() ) {
traverse( l[i], depth - 1 );
}
} catch( IOException ioe ) {
System.out.println( l[i] + ":" );
ioe.printStackTrace( System.out );
}
}
}
示例4: main
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
public static void main( String argv[] ) throws Exception
{
if (argv.length < 2) {
System.err.println("usage: TestListLoop <smburl> <count>");
System.exit(0);
}
int count = Integer.parseInt(argv[1]);
for ( ;; ) {
try {
SmbFile f = new SmbFile(argv[0]);
SmbFile[] list = f.listFiles();
System.out.println("Successfully listed resource: " + list.length);
} catch (SmbException se) {
se.printStackTrace();
}
if (--count <= 0)
break;
Thread.sleep( 1000 );
}
}
示例5: jcifsScan
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
public static void jcifsScan(String root, int sleepTime) throws Exception {
long start = System.currentTimeMillis();
SmbFile smbRoot = new SmbFile(root);
SmbFile[] files = smbRoot.listFiles();
for(SmbFile f : files) {
System.out.println( f + ": " + f.canRead()+" : "+ f.length() + ": " + (System.currentTimeMillis()-start));
Thread.sleep(sleepTime);
}
}
示例6: main
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
public static void main( String[] argv ) throws Exception {
SmbFile file = new SmbFile( argv[0] );
long t1 = System.currentTimeMillis();
SmbFile[] files = file.listFiles();
long t2 = System.currentTimeMillis() - t1;
for( int i = 0; i < files.length; i++ ) {
System.out.print( " " + files[i].getName() );
switch(files[i].getType()) {
case SmbFile.TYPE_FILESYSTEM:
System.out.println( "[TYPE_FILESYSTEM]" );
break;
case SmbFile.TYPE_WORKGROUP:
System.out.println( "[TYPE_WORKGROUP]" );
break;
case SmbFile.TYPE_SERVER:
System.out.println( "[TYPE_SERVER]" );
break;
case SmbFile.TYPE_SHARE:
System.out.println( "[TYPE_SHARE]" );
break;
case SmbFile.TYPE_NAMED_PIPE:
System.out.println( "[TYPE_NAMEDPIPE]" );
break;
case SmbFile.TYPE_PRINTER:
System.out.println( "[TYPE_PRINTER]" );
break;
case SmbFile.TYPE_COMM:
System.out.println( "[TYPE_COMM]" );
break;
};
}
System.out.println( files.length + " files in " + t2 + "ms" );
}
示例7: listDirs
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
/**
* 디렉토리 목록 조회
*
* @param sbmFile
* @return
* @throws Exception
*/
public static SmbFile[] listDirs(SmbFile sbmFile) throws Exception {
return sbmFile.listFiles(new SmbFileFilter() {
public boolean accept(SmbFile arg0) throws SmbException {
return arg0.isDirectory();
}
});
}
示例8: listFile
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
/**
* 디렉토리 목록 조회
*
* @param sbmFile
* @return
* @throws Exception
*/
public static SmbFile[] listFile(SmbFile sbmFile) throws Exception {
return sbmFile.listFiles(new SmbFileFilter() {
public boolean accept(SmbFile arg0) throws SmbException {
return arg0.isFile();
}
});
}
示例9: main
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
public static void main(String[] args) throws LoginException {
if(args.length != 5){
help();
return;
}
NAME = args[0];
PWD = args[1];
URL = args[2];
KDC = args[3];
REALM = args[4];
Config.setProperty("jcifs.smb.client.capabilities",Kerb5Authenticator.CAPABILITIES);
Config.setProperty("jcifs.smb.client.flags2",Kerb5Authenticator.FLAGS2);
Config.setProperty("jcifs.smb.client.signingPreferred", "true");
try {
// login
Subject subject = new Subject();
login(subject);
// list file
SmbFile file = new SmbFile(URL, new Kerb5Authenticator(subject));
SmbFile[] files = file.listFiles();
for( int i = 0; i < files.length; i++ ) {
System.out.println( "-->" + files[i].getName() );
System.out.println("DFS path: " + files[i].getDfsPath());
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: main
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
public static void main( String[] argv ) throws Exception {
for (int a = 0; a < argv.length; a++) {
SmbFile file = new SmbFile( argv[a], NtlmPasswordAuthentication.ANONYMOUS );
SmbFile[] files = file.listFiles();
for( int i = 0; i < files.length; i++ ) {
System.out.print( " " + files[i].getName() );
}
}
}
示例11: traverse
import jcifs.smb.SmbFile; //導入方法依賴的package包/類
void traverse( SmbFile f, int depth ) throws MalformedURLException, IOException {
if( depth == 0 ) {
return;
}
SmbFile[] l = f.listFiles();
for(int i = 0; l != null && i < l.length; i++ ) {
try {
int attrs = l[i].getAttributes();
if(( attrs & 0x7FEE ) != 0) {
if(( attrs & 0x7FCE ) != 0) {
numMeta++;
}
numMetaWithArch++;
}
for (int b = 0; b < 16; b++) {
if(( attrs & (1 << b)) != 0 ) {
permissionCounts[b]++;
}
}
System.out.print( Hexdump.toHexString( l[i].getAttributes(), 4 ) + ": " );
for( int j = maxDepth - depth; j > 0; j-- ) {
System.out.print( " " );
}
System.out.println( l[i].getName() );
if( l[i].isDirectory() ) {
traverse( l[i], depth - 1 );
}
if(( attrs & SmbFile.ATTR_DIRECTORY ) != 0 ) {
numDirectories++;
} else {
numFiles++;
}
} catch( IOException ioe ) {
System.out.println( l[i] + ": " + ioe.getMessage() );
}
}
}