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()); }
/** * List the contents of this SMB resource. The list returned will be * identical to the list returned by the parameterless <code>listFiles()</code> * method minus filenames filtered by the specified filter. * * @param filter a file filter to exclude files from the results * @return An array of <tt>SmbFile</tt> objects */ public SmbFile[] listFiles( SmbFileFilter filter ) throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, filter ); } String[] list( String wildcard, int searchAttributes,
/** * List the contents of this SMB resource. The list returned will be * identical to the list returned by the parameterless <code>listFiles()</code> * method minus filenames filtered by the specified filter. * * @param filter a file filter to exclude files from the results * @return An array of <tt>SmbFile</tt> objects */ public SmbFile[] listFiles( SmbFileFilter filter ) throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, filter ); } String[] list( String wildcard, int searchAttributes,
/** * List the contents of this SMB resource. The list returned will be * identical to the list returned by the parameterless <code>listFiles()</code> * method minus filenames filtered by the specified filter. * * @param filter a file filter to exclude files from the results * @return An array of <tt>SmbFile</tt> objects */ public SmbFile[] listFiles( SmbFileFilter filter ) throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, filter ); } String[] list( String wildcard, int searchAttributes,
/** * List the contents of this SMB resource. The list returned will be * identical to the list returned by the parameterless <code>listFiles()</code> * method minus filenames filtered by the specified filter. * * @param filter a file filter to exclude files from the results * @return An array of <tt>SmbFile</tt> objects */ public SmbFile[] listFiles( SmbFileFilter filter ) throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, filter ); } String[] list( String wildcard, int searchAttributes,
/** * List the contents of this SMB resource. The list returned will be * identical to the list returned by the parameterless <code>listFiles()</code> * method minus files filtered by the specified filename filter. * * @param filter a filter to exclude files from the results * @return An array of <tt>SmbFile</tt> objects * @throws SmbException */ public SmbFile[] listFiles( SmbFilenameFilter filter ) throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, filter, null ); } /**
/** * List the contents of this SMB resource. The list returned will be * identical to the list returned by the parameterless <code>listFiles()</code> * method minus files filtered by the specified filename filter. * * @param filter a filter to exclude files from the results * @return An array of <tt>SmbFile</tt> objects * @throws SmbException */ public SmbFile[] listFiles( SmbFilenameFilter filter ) throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, filter, null ); } /**
/** * List the contents of this SMB resource. The list returned will be * identical to the list returned by the parameterless <code>listFiles()</code> * method minus files filtered by the specified filename filter. * * @param filter a filter to exclude files from the results * @return An array of <tt>SmbFile</tt> objects * @throws SmbException */ public SmbFile[] listFiles( SmbFilenameFilter filter ) throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, filter, null ); } /**
/** * List the contents of this SMB resource. The list returned will be * identical to the list returned by the parameterless <code>listFiles()</code> * method minus files filtered by the specified filename filter. * * @param filter a filter to exclude files from the results * @return An array of <tt>SmbFile</tt> objects * @throws SmbException */ public SmbFile[] listFiles( SmbFilenameFilter filter ) throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, filter, null ); } /**
/** * List the contents of this SMB resource as an array of * <code>SmbFile</code> objects. This method is much more efficient than * the regular <code>list</code> method when querying attributes of each * file in the result set. * <p> * The list of <code>SmbFile</code>s returned by this method will be; * * <ul> * <li> files and directories contained within this resource if the * resource is a normal disk file directory, * <li> all available NetBIOS workgroups or domains if this resource is * the top level URL <code>smb://</code>, * <li> all servers registered as members of a NetBIOS workgroup if this * resource refers to a workgroup in a <code>smb://workgroup/</code> URL, * <li> all browseable shares of a server including printers, IPC * services, or disk volumes if this resource is a server URL in the form * <code>smb://server/</code>, * <li> or <code>null</code> if the resource cannot be resolved. * </ul> * * @return An array of <code>SmbFile</code> objects representing file * and directories, workgroups, servers, or shares depending on the context * of the resource URL */ public SmbFile[] listFiles() throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); }
/** * List the contents of this SMB resource as an array of * <code>SmbFile</code> objects. This method is much more efficient than * the regular <code>list</code> method when querying attributes of each * file in the result set. * <p> * The list of <code>SmbFile</code>s returned by this method will be; * * <ul> * <li> files and directories contained within this resource if the * resource is a normal disk file directory, * <li> all available NetBIOS workgroups or domains if this resource is * the top level URL <code>smb://</code>, * <li> all servers registered as members of a NetBIOS workgroup if this * resource refers to a workgroup in a <code>smb://workgroup/</code> URL, * <li> all browseable shares of a server including printers, IPC * services, or disk volumes if this resource is a server URL in the form * <code>smb://server/</code>, * <li> or <code>null</code> if the resource cannot be resolved. * </ul> * * @return An array of <code>SmbFile</code> objects representing file * and directories, workgroups, servers, or shares depending on the context * of the resource URL */ public SmbFile[] listFiles() throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); }
/** * List the contents of this SMB resource as an array of * <code>SmbFile</code> objects. This method is much more efficient than * the regular <code>list</code> method when querying attributes of each * file in the result set. * <p> * The list of <code>SmbFile</code>s returned by this method will be; * * <ul> * <li> files and directories contained within this resource if the * resource is a normal disk file directory, * <li> all available NetBIOS workgroups or domains if this resource is * the top level URL <code>smb://</code>, * <li> all servers registered as members of a NetBIOS workgroup if this * resource refers to a workgroup in a <code>smb://workgroup/</code> URL, * <li> all browseable shares of a server including printers, IPC * services, or disk volumes if this resource is a server URL in the form * <code>smb://server/</code>, * <li> or <code>null</code> if the resource cannot be resolved. * </ul> * * @return An array of <code>SmbFile</code> objects representing file * and directories, workgroups, servers, or shares depending on the context * of the resource URL */ public SmbFile[] listFiles() throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); }
/** * List the contents of this SMB resource as an array of * <code>SmbFile</code> objects. This method is much more efficient than * the regular <code>list</code> method when querying attributes of each * file in the result set. * <p> * The list of <code>SmbFile</code>s returned by this method will be; * * <ul> * <li> files and directories contained within this resource if the * resource is a normal disk file directory, * <li> all available NetBIOS workgroups or domains if this resource is * the top level URL <code>smb://</code>, * <li> all servers registered as members of a NetBIOS workgroup if this * resource refers to a workgroup in a <code>smb://workgroup/</code> URL, * <li> all browseable shares of a server including printers, IPC * services, or disk volumes if this resource is a server URL in the form * <code>smb://server/</code>, * <li> or <code>null</code> if the resource cannot be resolved. * </ul> * * @return An array of <code>SmbFile</code> objects representing file * and directories, workgroups, servers, or shares depending on the context * of the resource URL */ public SmbFile[] listFiles() throws SmbException { return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); }
return listFiles( wildcard, ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null );
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("", username, password); // username and password which you use for logging into your Windows PC SmbFile network; try { network = new SmbFile("smb://servername or IPAddress", auth); for (SmbFile node : network.listFiles()) { // network path is now contained in 'node' } } catch (MalformedURLException e) { e.printStackTrace(); } catch (SmbException e) { e.printStackTrace(); }
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()); }
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()); }
protected String doInBackground(String... params) { SmbFile[] domains; String username = USERNAME; String password = PASSWORD; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("", username, password); try { SmbFile sm = new SmbFile(SMB_URL, auth); domains = sm.listFiles(); for (int i = 0; i < domains.length; i++) { SmbFile[] servers = domains[i].listFiles(); for (int j = 0; j < servers.length; j++) { Log.w(" Files ", "\t"+servers[j]); } } } catch (SmbException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } return ""; }
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(); }