java dir.exists_Java SmbFile.exists方法代码示例

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 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);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值