本文整理汇总了Java中jcifs.smb.SmbFile.delete方法的典型用法代码示例。如果您正苦于以下问题:Java SmbFile.delete方法的具体用法?Java SmbFile.delete怎么用?Java SmbFile.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jcifs.smb.SmbFile
的用法示例。
在下文中一共展示了SmbFile.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: smbDel
import jcifs.smb.SmbFile; //导入方法依赖的package包/类
/**
* 把本地磁盘中的文件从局域网共享文件中删除
*
* @param remoteUrl
* 共享电脑路径 如:smb//administrator:[email protected]/smb
*/
public static void smbDel(String remoteUrl) {
try {
SmbFile remoteFile = new SmbFile(SMBPATH + remoteUrl);
if (remoteFile.isFile() && remoteFile.exists()) {
remoteFile.delete();
logger.info("删除远程文件 :" + remoteUrl);
}
} catch (Exception e) {
logger.error(e);
}
}
示例2: delete
import jcifs.smb.SmbFile; //导入方法依赖的package包/类
@Override
public boolean delete(String srcPath) throws IOException {
if (isDirectory(srcPath) && !srcPath.endsWith("/")){
srcPath+="/";
}
SmbFile currentFolder = new SmbFile(getAbsolutePath(srcPath), authentication);
try {
currentFolder.delete();
return true;
} catch (Exception e){
e.printStackTrace();
return false;
}
}
示例3: deleteOnRemote
import jcifs.smb.SmbFile; //导入方法依赖的package包/类
/**
* @param remoteFile
* @param remoteFolder
* @throws IOException
*/
private void deleteOnRemote(String remoteFile, String remoteFolder) throws IOException {
String dir = "";
if (remoteFolder != null)
dir = remoteFolder + File.separator;
String fname = share + File.separator + dir + remoteFile;
fname = fname.replace('\\', '/');
SmbFile file = new SmbFile(fname, auth);
file.delete();
}
示例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);
}
}
示例5: delete
import jcifs.smb.SmbFile; //导入方法依赖的package包/类
/**
* Deletes the file under the provided {@link SMBPath}
*
* @param path {@link SMBPath} to file that should be deleted.
*
* @throws IllegalArgumentException If provided path is not an {@link SMBPath} instance.
* @throws IOException If deleting the file fails for some reason.
*/
@Override
public void delete(Path path) throws IOException {
SmbFile smbFile = SMBPath.fromPath(path).getSmbFile();
smbFile.delete();
}