本文整理汇总了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();
}
示例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();
}
示例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();
}
}
}
示例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();
}
示例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();
}
}
}
示例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"
}
}
示例7: main
import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
public static void main( String argv[] ) throws Exception {
SmbFileOutputStream out = new SmbFileOutputStream( argv[0], false );
out.close();
}
示例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);
}
示例9: getOutputStream
import jcifs.smb.SmbFileOutputStream; //导入依赖的package包/类
@Override
protected OutputStream getOutputStream(ServerPath path) throws IOException {
return new SmbFileOutputStream(getFile(path));
}
示例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);
}