String url = "smb://yourhost/yourpath/"; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, "user", "password"); SmbFile dir = new SmbFile(url, auth); for (SmbFile f : dir.listFiles()) { System.out.println(f.getName()); }
public String getName() throws IOException { if (isFile()) return getFSFile().getName(); if (isSMB()) try { return getSmbFile().getName(); } catch (final MalformedURLException e) { throw new IOException("SMB.getName MalformedURLException (" + e.getMessage() + ") for " + toNormalform(false) ); } if (isFTP()) { return this.getFileName(); } return null; }
@Override protected String getFilename(SmbFile file) { return file.getName(); }
/** * Gets the specified SMB file's name. * @param file SMB file object * @return file name * @see AbstractRegexPatternFileListFilter#getFilename(java.lang.Object) */ @Override protected String getFilename(SmbFile file) { return (file != null ? file.getName() : null); }
/** * Gets the specified SMB file's name. * @param file SMB file object * @return file name * @see AbstractSimplePatternFileListFilter#getFilename(java.lang.Object) */ @Override protected String getFilename(SmbFile file) { return (file != null) ? file.getName() : null; }
@Override protected String getFilename(SmbFile _file) { return _file != null ? _file.getName() : null; }
String url = "smb://[NAS server-IP or hostname]/file-or-directory-path"; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("[company network domain]", "user", "password"); SmbFile dir = new SmbFile(url, auth); for (SmbFile f : dir.listFiles()) { System.out.println(f.getName()); }
String sharedPath = "smb://IPaddress/Content/"; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, "username", "password"); SmbFile dir = new SmbFile(sharedPath, auth); System.out.println(dir.listFiles()); for (SmbFile f : dir.listFiles()) { System.out.println("Source file name is: " + f.getName()); }
protected int compareNames( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } return f1name.compareToIgnoreCase( f2.getName() ); } protected int compareSizes( SmbFile f1, String f1name, SmbFile f2 ) throws IOException {
protected int compareNames( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } return f1name.compareToIgnoreCase( f2.getName() ); } protected int compareSizes( SmbFile f1, String f1name, SmbFile f2 ) throws IOException {
protected int compareNames ( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if ( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } return f1name.compareToIgnoreCase(f2.getName()); }
protected int compareNames( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } return f1name.compareToIgnoreCase( f2.getName() ); } protected int compareSizes( SmbFile f1, String f1name, SmbFile f2 ) throws IOException {
protected int compareNames ( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if ( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } return f1name.compareToIgnoreCase(f2.getName()); }
protected int compareDates ( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if ( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } if ( f1.isDirectory() ) { return f1name.compareToIgnoreCase(f2.getName()); } return f1.lastModified() > f2.lastModified() ? -1 : 1; }
protected int compareDates( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } if( f1.isDirectory() ) { return f1name.compareToIgnoreCase( f2.getName() ); } return f1.lastModified() > f2.lastModified() ? -1 : 1; } protected void doDirectory( HttpServletRequest req, HttpServletResponse resp, SmbFile dir ) throws IOException {
protected int compareDates ( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if ( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } if ( f1.isDirectory() ) { return f1name.compareToIgnoreCase(f2.getName()); } return f1.lastModified() > f2.lastModified() ? -1 : 1; }
protected int compareDates( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } if( f1.isDirectory() ) { return f1name.compareToIgnoreCase( f2.getName() ); } return f1.lastModified() > f2.lastModified() ? -1 : 1; } protected void doDirectory( HttpServletRequest req, HttpServletResponse resp, SmbFile dir ) throws IOException {
protected int compareDates( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } if( f1.isDirectory() ) { return f1name.compareToIgnoreCase( f2.getName() ); } return f1.lastModified() > f2.lastModified() ? -1 : 1; } protected void doDirectory( HttpServletRequest req, HttpServletResponse resp, SmbFile dir ) throws IOException {
public void pullUp(String from, String to) throws IOException, InterruptedException { SmbFile src = $(from); SmbFile dst = $(to); for (SmbFile e : src.listFiles()) { e.renameTo(new SmbFile(dst,e.getName())); } src.delete(); }
public void pullUp(String from, String to) throws IOException, InterruptedException { SmbFile src = $(from); SmbFile dst = $(to); for (SmbFile e : src.listFiles()) { e.renameTo(new SmbFile(dst,e.getName())); } src.delete(); }