当前位置: 首页>>代码示例>>Java>>正文


Java SmbFileOutputStream类代码示例

本文整理汇总了Java中jcifs.smb.SmbFileOutputStream的典型用法代码示例。如果您正苦于以下问题:Java SmbFileOutputStream类的具体用法?Java SmbFileOutputStream怎么用?Java SmbFileOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SmbFileOutputStream类属于jcifs.smb包,在下文中一共展示了SmbFileOutputStream类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
public static void main( String argv[] ) throws Exception {

        SmbFile f = new SmbFile( argv[0] );
        FileInputStream in = new FileInputStream( f.getName() );
        SmbFileOutputStream out = new SmbFileOutputStream( f );

        long t0 = System.currentTimeMillis();

        byte[] b = new byte[8192];
        int n, tot = 0;
        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();
    }
 
开发者ID:codelibs,项目名称:jcifs,代码行数:25,代码来源:Put.java

示例2: main

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
public static void main( String argv[] ) throws Exception {

        SmbFile f = new SmbFile( argv[0] );
        SmbFileOutputStream out = new SmbFileOutputStream( f, true );

        byte[] msg;
        int i = 0;
        while( i++ < 3 ) {
            msg = new String( "this is msg #" + i ).getBytes();
            out.write( msg );
            System.out.write( msg );
            Thread.sleep( 10000 );
//out = new SmbFileOutputStream( f, true );
        }

        out.close();
    }
 
开发者ID:codelibs,项目名称:jcifs,代码行数:18,代码来源:Append.java

示例3: testReadOnly

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
@Test
public void testReadOnly () throws IOException {
    try ( SmbFile f = createTestFile() ) {
        try {
            try ( SmbFileOutputStream os = f.openOutputStream() ) {
                os.write(new byte[] {
                    0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7
                });
            }

            byte[] buf = new byte[4];
            try ( SmbRandomAccessFile raf = new SmbRandomAccessFile(f, "r") ) {
                raf.seek(4);
                raf.readFully(buf);
            }

            Assert.assertArrayEquals(new byte[] {
                0x4, 0x5, 0x6, 0x7
            }, buf);
        }
        finally {
            f.delete();
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:26,代码来源:RandomAccessFileTest.java

示例4: main

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
public static void main( String argv[] ) throws Exception {

        SmbFileOutputStream out = new SmbFileOutputStream( argv[0] );

        for( int i = 0; i < 2; i++ ) {
            out.write( (new String( "hello" + i )).getBytes() );
            Thread.sleep( 17000 );
        }

        out.close();
    }
 
开发者ID:codelibs,项目名称:jcifs,代码行数:12,代码来源:SlowWrite.java

示例5: testReadOnlySeekOOB

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
@Test
public void testReadOnlySeekOOB () throws IOException {
    try ( SmbFile f = createTestFile() ) {
        try {
            try ( SmbFileOutputStream os = f.openOutputStream() ) {
                os.write(new byte[] {
                    0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7
                });
            }

            try ( SmbRandomAccessFile raf = new SmbRandomAccessFile(f, "r") ) {
                raf.seek(10);
                Assert.assertEquals(-1, raf.read());
            }

            byte[] buf = new byte[4];
            try ( SmbRandomAccessFile raf = new SmbRandomAccessFile(f, "r") ) {
                raf.seek(6);
                Assert.assertEquals(2, raf.read(buf));
                Assert.assertArrayEquals(new byte[] {
                    0x6, 0x7, 0x0, 0x0
                }, buf);
            }

            try ( SmbRandomAccessFile raf = new SmbRandomAccessFile(f, "r") ) {
                raf.seek(6);
                try {
                    raf.readFully(buf);
                    Assert.fail("Should have thrown exception");
                }
                catch ( SmbEndOfFileException e ) {}
            }

        }
        finally {
            f.delete();
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:40,代码来源:RandomAccessFileTest.java

示例6: getOutputStream

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
@Override
public OutputStream getOutputStream(boolean append) throws IOException {
	ResourceUtil.checkGetOutputStreamOK(this);
	try {
		provider.lock(this);
		SmbFile file =_file();
		OutputStream os = new SmbFileOutputStream(file, append);
		return IOUtil.toBufferedOutputStream(new ResourceOutputStream(this,os));
	}
	catch (IOException e) {
		provider.unlock(this);
		throw new IOException(e);// just in case it is an SmbException too... for cfcatch type="java.io.IOException"
	}
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:15,代码来源:SMBResource.java

示例7: main

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
public static void main( String argv[] ) throws Exception {

        SmbFileOutputStream out = new SmbFileOutputStream( argv[0], false );
        out.close();
    }
 
开发者ID:codelibs,项目名称:jcifs,代码行数:6,代码来源:CreateFile.java

示例8: doGetOutputStream

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
/**
 * Creates an output stream to write the file content to.
 */
@Override
protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
{
    return new SmbFileOutputStream(file, bAppend);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:9,代码来源:SmbFileObject.java

示例9: getOutputStream

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
@Override
protected OutputStream getOutputStream(ServerPath path) throws IOException {
	return new SmbFileOutputStream(getFile(path));
}
 
开发者ID:beckchr,项目名称:musicmount,代码行数:5,代码来源:SMBResourceProvider.java

示例10: doGetOutputStream

import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
/**
 * Creates an output stream to write the file content to.
 */
protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
{
    return new SmbFileOutputStream(file, bAppend);
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:8,代码来源:SmbFileObject.java


注:本文中的jcifs.smb.SmbFileOutputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。