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


Java SmbFile.createNewFile方法代码示例

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


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

示例1: SeekableSMBByteChannel

import jcifs.smb.SmbFile; //导入方法依赖的package包/类
/**
 * Constructor for {@link SeekableSMBByteChannel}
 *
 * @param file The {@link SmbFile} instance that should be opened.
 * @param write Flag that indicates, whether write access is requested.
 * @param create Flag that indicates, whether file should be created.
 * @param create_new Flag that indicates, whether file should be created. If it is set to true, operation will fail if file exists!
 * @param truncate Flag that indicates, whether file should be truncated to length 0 when being opened.
 * @param append Flag that indicates, whether data should be appended.
 * @throws IOException If something goes wrong when accessing the file.
 */
SeekableSMBByteChannel(SmbFile file, boolean write, boolean create, boolean create_new, boolean truncate, boolean append) throws IOException {

    /*  Tries to create a new file, if so specified. */
    if (create || create_new) {
        if (file.exists()) {
            if (create_new) throw new FileAlreadyExistsException("The specified file '" + file.getPath() + "' does already exist!");
        } else {
            file.createNewFile();
        }
    }

    /* Opens the file with either read only or write access. */
    if (write) {
        file.setReadWrite();
        this.random = new SmbRandomAccessFile(file, "rw");
        if (truncate) this.random.setLength(0);
        if (append) this.random.seek(this.random.length());
    } else {
        file.setReadOnly();
        this.random = new SmbRandomAccessFile(file, "r");
    }
}
 
开发者ID:pontiussoftware,项目名称:smb-nio,代码行数:34,代码来源:SeekableSMBByteChannel.java

示例2: createFile

import jcifs.smb.SmbFile; //导入方法依赖的package包/类
@Override
public EncFSFileInfo createFile(String dstFilePath) throws IOException {
	System.out.println("create file "+dstFilePath);
	SmbFile currentFolder = new SmbFile(getAbsolutePath(dstFilePath), authentication);
	currentFolder.createNewFile();
	return getFileInfo(dstFilePath);
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:8,代码来源:FileProvider3.java

示例3: createTestFile

import jcifs.smb.SmbFile; //导入方法依赖的package包/类
protected SmbFile createTestFile () throws MalformedURLException, UnknownHostException, CIFSException {
    try ( SmbFile defaultShareRoot = getDefaultShareRoot() ) {
        SmbFile f = new SmbFile(defaultShareRoot, makeRandomName());
        f.createNewFile();
        return f;
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:BaseCIFSTest.java

示例4: beforeClass

import jcifs.smb.SmbFile; //导入方法依赖的package包/类
@BeforeClass
void beforeClass() throws IOException {
    Properties properties = new Properties();
    InputStream propertiesInput = new FileInputStream(PROPERTIES);
    try {
        properties.load(propertiesInput);

        for (String prop : requiredProperties) {
            if (properties.getProperty(prop, "").isEmpty()) {
                throw new IllegalStateException("Missing required property " + prop + " in " + PROPERTIES);
            }
        }
        SERVER = properties.getProperty("SERVER");
        SERVER_IP = properties.getProperty("SERVER_IP");
        SHARE = properties.getProperty("SHARE");
        DIR = properties.getProperty("DIR");

        WRITE_DIR = DIR + "/";
        SRC_DIR = DIR + "/Junk/";
        FILE1 = SRC_DIR + "10883563.doc";
        URL_SERVER = "smb://" + SERVER + "/";
        URL_SHARE = URL_SERVER + SHARE + "/";
        URL_WRITE_DIR = URL_SHARE + WRITE_DIR;

        for (Map.Entry<Object,Object> propEntry : properties.entrySet()) {
            System.setProperty((String)propEntry.getKey(), (String)propEntry.getValue());
        }

        SmbFile dir = new SmbFile(URL_WRITE_DIR);
        if (dir.exists()) {
            dir.delete();
        }
        SmbFile srcDir = new SmbFile(URL_SHARE + SRC_DIR);
        if (!srcDir.exists()) {
            srcDir.mkdirs();
        }
        SmbFile file1 = new SmbFile(URL_SHARE + FILE1);
        if (!file1.exists()) {
            file1.createNewFile();
            OutputStream os = file1.getOutputStream();
            try {
                IOUtils.copy(getClass().getResourceAsStream("10883563.doc"), os);
            } finally {
                IOUtils.closeQuietly(os);
            }
        }

    } finally {
        IOUtils.closeQuietly(propertiesInput);
    }
}
 
开发者ID:IdentityAutomation,项目名称:jcifs-idautopatch,代码行数:52,代码来源:JCIFSTest.java


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