Tabnine Logo
jcifs.smb
Code IndexAdd Tabnine to your IDE (free)

How to use jcifs.smb

Best Java code snippets using jcifs.smb (Showing top 20 results out of 315)

origin: stackoverflow.com

 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());
}
origin: stackoverflow.com

String user = "your_user_name";
 String pass ="your_pass_word";
 String sharedFolder="shared";
 String path="smb://ip_address/"+sharedFolder+"/test.txt";
 NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",user, pass);
 SmbFile smbFile = new SmbFile(path,auth);
 SmbFileOutputStream smbfos = new SmbFileOutputStream(smbFile);
 smbfos.write("testing....and writing to a file".getBytes());
 System.out.println("completed ...nice !");
origin: yacy/yacy_grid_mcp

  @Override
  public String[] call() { try {
    return file.list();
  } catch (final SmbException e) {
    //Log.logWarning("TimeoutRequest:list", file.toString() + " - no list", e);
    return null;
  } }
}).call(timeout);
origin: yacy/yacy_grid_mcp

/**
 * Get directory listing of file or smb url
 * respects the hidden attribute of a directory (return null if hidden)
 * 
 * @return names of files and directories or null
 * @throws IOException
 */
public String[] list() throws IOException {
  if (isFile() && !isHidden()) return getFSFile().list();
  if (isSMB()) try {
    final SmbFile sf = getSmbFile();
    if (!sf.isDirectory() || sf.isHidden()) return null;
    try {
      return TimeoutRequest.list(sf, SMB_TIMEOUT);
    } catch (final SmbException e) {
      throw new IOException("SMB.list SmbException for " + sf.toString() + ": " + e.getMessage());
    }
  } catch (final MalformedURLException e) {
    throw new IOException("SMB.list MalformedURLException for " + toNormalform(false) + ": " + e.getMessage());
  }
  return null;
}
origin: stackoverflow.com

 SmbFile server = new SmbFile("smb://server/");
String[] shares = server.list();
origin: stackoverflow.com

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, null, null);
origin: yacy/yacy_grid_mcp

  @Override
  public Long call() { try {
    return file.length();
  } catch (final SmbException e) {
    return Long.valueOf(0);
  } }
}).call(timeout).longValue();
origin: yacy/yacy_grid_mcp

/**
 * create a smb File
 * Please call isSMB() before using this class
 * @throws MalformedURLException
 */
public SmbFile getSmbFile() throws MalformedURLException {
  if (!isSMB()) throw new MalformedURLException();
  final String url = unescape(this.toNormalform(true));
  return new SmbFile(url);
}
origin: yacy/yacy_grid_mcp

  @Override
  public Boolean call() { try {
    return file.exists();
  } catch (final SmbException e) {
    return Boolean.FALSE;
  } }
}).call(timeout).booleanValue();
origin: yacy/yacy_grid_mcp

public long lastModified() throws IOException {
  if (isFile()) return getFSFile().lastModified();
  if (isSMB()) try {
    return getSmbFile().lastModified();
    // return TimeoutRequest.lastModified(getSmbFile(), SMB_TIMEOUT); // a timeout request is a bad idea, that will create a lot of concurrent threads during crawling
  } catch (final SmbException e) {
    throw new IOException("SMB.lastModified SmbException (" + e.getMessage() + ") for " + toNormalform(false));
  } catch (final MalformedURLException e) {
    throw new IOException("SMB.lastModified MalformedURLException (" + e.getMessage() + ") for " + toNormalform(false));
  }
  return 0;
}
origin: yacy/yacy_grid_mcp

  @Override
  public Boolean call() { try {
    return file.isDirectory();
  } catch (final SmbException e) {
    return Boolean.FALSE;
  } }
}).call(timeout).booleanValue();
origin: yacy/yacy_grid_mcp

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;
}
origin: yacy/yacy_grid_mcp

  @Override
  public Long call() { try {
    return file.lastModified();
  } catch (final SmbException e) {
    return Long.valueOf(0);
  } }
}).call(timeout).longValue();
origin: yacy/yacy_grid_mcp

public boolean isDirectory() throws IOException {
  if (isFile()) return getFSFile().isDirectory();
  if (isSMB()) try {
    return TimeoutRequest.isDirectory(getSmbFile(), SMB_TIMEOUT);
  } catch (final SmbException e) {
    throw new IOException("SMB.isDirectory SmbException (" + e.getMessage() + ") for " + toNormalform(false));
  } catch (final MalformedURLException e) {
    throw new IOException("SMB.isDirectory MalformedURLException (" + e.getMessage() + ") for " + toNormalform(false));
  }
  return false;
}
origin: yacy/yacy_grid_mcp

  @Override
  public Boolean call() { try {
    return file.canRead();
  } catch (final SmbException e) {
    return Boolean.FALSE;
  } }
}).call(timeout).booleanValue();
origin: yacy/yacy_grid_mcp

  @Override
  public Boolean call() { try {
    return file.isHidden();
  } catch (final SmbException e) {
    return Boolean.FALSE;
  } }
}).call(timeout).booleanValue();
origin: yacy/yacy_grid_mcp

  @Override
  public Boolean call() { try {
    return file.canWrite();
  } catch (final SmbException e) {
    return Boolean.FALSE;
  } }
}).call(timeout).booleanValue();
origin: yacy/yacy_grid_mcp

public long length() {
  if (isFile()) try {
    return getFSFile().length();
  } catch (final Throwable e) {
    return -1;
  }
  if (isSMB()) try {
    return getSmbFile().length();
    //return TimeoutRequest.length(getSmbFile(), SMB_TIMEOUT); // a timeout request is a bad idea, that will create a lot of concurrent threads during crawling
  } catch (final Throwable e) {
    return -1;
  }
  return -1;
}
origin: yacy/yacy_grid_mcp

public boolean exists() throws IOException {
  if (isFile()) return getFSFile().exists();
  if (isSMB()) try {
    return TimeoutRequest.exists(getSmbFile(), SMB_TIMEOUT);
  } catch (final SmbException e) {
    throw new IOException("SMB.exists SmbException (" + e.getMessage() + ") for " + toNormalform(false));
  } catch (final MalformedURLException e) {
    throw new IOException("SMB.exists MalformedURLException (" + e.getMessage() + ") for " + toNormalform(false));
  }
  return false;
}
origin: yacy/yacy_grid_mcp

public boolean canRead() throws IOException {
  if (isFile()) return getFSFile().canRead();
  if (isSMB()) try {
    return TimeoutRequest.canRead(getSmbFile(), SMB_TIMEOUT);
  } catch (final SmbException e) {
    throw new IOException("SMB.canRead SmbException (" + e.getMessage() + ") for " + toNormalform(false));
  } catch (final MalformedURLException e) {
    throw new IOException("SMB.canRead MalformedURLException (" + e.getMessage() + ") for " + toNormalform(false));
  }
  return false;
}
jcifs.smb

Most used classes

  • NtlmPasswordAuthentication
    This class stores and encrypts NTLM user credentials. The default credentials are retrieved from the
  • SmbFile
    This class represents a resource on an SMB network. Mainly these resources are files and directories
  • SmbException
    There are hundreds of error codes that may be returned by a CIFS server. Rather than represent each
  • SmbFileInputStream
    This InputStream can read bytes from a file on an SMB file server. Offsets are 64 bits.
  • SmbFileOutputStream
    This OutputStream can write bytes to a file on an SMB file server.
  • SmbNamedPipe,
  • SmbSession,
  • SmbRandomAccessFile,
  • DfsReferral,
  • FileEntry,
  • Handler,
  • NtlmAuthenticator,
  • NtlmChallenge,
  • NtlmContext,
  • SID,
  • SmbFileFilter,
  • SmbFilenameFilter,
  • ACE,
  • AllocInfo
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now