Package jcifs.smb

Examples of jcifs.smb.SmbFileInputStream


    /**
     * Creates an input stream to read the file content from.
     */
    protected InputStream doGetInputStream() throws Exception
    {
        return new SmbFileInputStream(file);
    }
View Full Code Here


        return null;
    }
   
    public InputStream getInputStream(final String userAgent, final int timeout) throws IOException {
        if (isFile()) return new FileInputStream(getFSFile());
        if (isSMB()) return new SmbFileInputStream(getSmbFile());
        if (isFTP()) {
            FTPClient client = new FTPClient();
            client.open(this.host, this.port < 0 ? 21 : this.port);
            byte[] b = client.get(this.path);
            client.CLOSE();
View Full Code Here

        return null;
    }
   
    public byte[] get(final String userAgent, final int timeout) throws IOException {
        if (isFile()) return read(new FileInputStream(getFSFile()));
        if (isSMB()) return read(new SmbFileInputStream(getSmbFile()));
        if (isFTP()) {
            FTPClient client = new FTPClient();
            client.open(this.host, this.port < 0 ? 21 : this.port);
            byte[] b = client.get(this.path);
            client.CLOSE();
View Full Code Here

    }
    public static void main(String[] args) {
        //jcifs.Config.setProperty( "jcifs.netbios.wins", "192.168.1.220" );
        //NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "username", "password");
        SmbFileInputStream in;
        try {
            SmbFile sf = new SmbFile(args[0]);
            if (sf.isDirectory()) {
                String[] s = sf.list();
                for (String t: s) System.out.println(t);
            } else {
                in = new SmbFileInputStream(sf);
                byte[] b = new byte[8192];
                int n;
                while(( n = in.read( b )) > 0 ) {
                    System.out.write( b, 0, n );
                }
            }
        } catch (SmbException e) {
            Log.logException(e);
View Full Code Here

public class Get {

    public static void main( String argv[] ) throws Exception {

        SmbFile f = new SmbFile( argv[0] );
        SmbFileInputStream in = new SmbFileInputStream( f );
        FileOutputStream out = new FileOutputStream( f.getName() );

        long t0 = System.currentTimeMillis();

        byte[] b = new byte[8192];
        int n, tot = 0;
        long t1 = t0;
        while(( n = in.read( b )) > 0 ) {
            out.write( b, 0, n );
            tot += n;
            System.out.print( '#' );
        }

        long t = System.currentTimeMillis() - t0;

        System.out.println();
        System.out.println( tot + " bytes transfered in " + ( t / 1000 ) + " seconds at " + (( tot / 1000 ) / Math.max( 1, ( t / 1000 ))) + "Kbytes/sec" );

        in.close();
        out.close();
    }
View Full Code Here

public class SlowRead {

    public static void main( String argv[] ) throws Exception {

        SmbFileInputStream in = new SmbFileInputStream( argv[0] );

        byte[] b = new byte[10];
        int n, tot = 0;
        while(( n = in.read( b )) > 0 ) {
            System.out.write( b, 0, n );
            tot += n;
            Thread.sleep( 10000 );
        }

        in.close();
    }
View Full Code Here

    @Override
    protected InputStream doGetInputStream() throws Exception
    {
        try
        {
            return new SmbFileInputStream(file);
        }
        catch (SmbException e)
        {
            if (e.getErrorCode() == SmbException.ERRbadfile)
            {
View Full Code Here

  // Access input stream from file
 
  public InputStream getInputStream() throws IOException {
    try {
      if (null != _smbFile) {
        return new SmbFileInputStream(_smbFile);
      }
      else if (null != _localFile) {
        return new FileInputStream(_localFile);
      }
    }
View Full Code Here

    }
    public static void main(String[] args) {
        //jcifs.Config.setProperty( "jcifs.netbios.wins", "192.168.1.220" );
        //NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "username", "password");
        SmbFileInputStream in;
        try {
            SmbFile sf = new SmbFile(args[0]);
            if (sf.isDirectory()) {
                String[] s = sf.list();
                for (String t: s) System.out.println(t);
            } else {
                in = new SmbFileInputStream(sf);
                byte[] b = new byte[8192];
                int n;
                while(( n = in.read( b )) > 0 ) {
                    System.out.write( b, 0, n );
                }
            }
        } catch (SmbException e) {
            Log.logException(e);
View Full Code Here

        return null;
    }

    public InputStream getInputStream(final String userAgent, final int timeout) throws IOException {
        if (isFile()) return new FileInputStream(getFSFile());
        if (isSMB()) return new SmbFileInputStream(getSmbFile());
        if (isFTP()) {
            final FTPClient client = new FTPClient();
            client.open(this.host, this.port < 0 ? 21 : this.port);
            final byte[] b = client.get(this.path);
            client.CLOSE();
View Full Code Here

TOP

Related Classes of jcifs.smb.SmbFileInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.