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


Java FileUtils.getInstance方法代码示例

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


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

示例1: deleteToTrash

import com.sun.jna.platform.FileUtils; //导入方法依赖的package包/类
/**
 * Deletes a file or directory.  If a system trash directory is available,
 * the file or directory will be moved there instead.
 * @param file the file or directory to delete
 * @return true if moved to trash, and false if deleted
 * @throws IOException if given file does not exist
 */
public static boolean deleteToTrash(File file) throws IOException {
	if (file == null)
		throw new IOException("File cannot be null.");
	if (!file.exists())
		throw new IOException(String.format("File '%s' does not exist.", file.getAbsolutePath()));

	// move to system trash, if possible
	FileUtils fileUtils = FileUtils.getInstance();
	if (fileUtils.hasTrash()) {
		try {
			fileUtils.moveToTrash(new File[] { file });
			return true;
		} catch (IOException e) {
			Log.warn(String.format("Failed to move file '%s' to trash.", file.getAbsolutePath()), e);
		}
	}

	// delete otherwise
	if (file.isDirectory())
		deleteDirectory(file);
	else
		file.delete();
	return false;
}
 
开发者ID:yugecin,项目名称:opsu-dance,代码行数:32,代码来源:Utils.java

示例2: moveToTrash

import com.sun.jna.platform.FileUtils; //导入方法依赖的package包/类
public static boolean moveToTrash(File fileToDelete)
{
    FileUtils fileUtils = FileUtils.getInstance();
    if (fileUtils.hasTrash())
    {
        try
        {
            fileUtils.moveToTrash( new File[] { fileToDelete } );
            return true;

        } catch (IOException ioe)
        {
        }
    }

    return false;
}
 
开发者ID:Webreaper,项目名称:GooglePhotoSync,代码行数:18,代码来源:FileUtilities.java

示例3: removeFile

import com.sun.jna.platform.FileUtils; //导入方法依赖的package包/类
/**
 * Move to trash if trash exist in OS, else remove from file system
 *
 * @param fileToRemove: file to be removed
 * @return true if file is removed successfully
 * @throws IOException
 */
public static boolean removeFile(File fileToRemove) throws IOException {
    FileUtils fileUtils = FileUtils.getInstance();
    if (fileUtils.hasTrash()) {
        fileUtils.moveToTrash( new File[]{fileToRemove} );
        return true;
    }
    else {
        return deleteFolderOrFile(fileToRemove);
    }
}
 
开发者ID:ijh165,项目名称:Gamma-Music-Manager,代码行数:18,代码来源:FileManager.java

示例4: moveToTrash

import com.sun.jna.platform.FileUtils; //导入方法依赖的package包/类
private void moveToTrash(File[] files) throws IOException {
	FileUtils fileUtils = FileUtils.getInstance();
	if(fileUtils.hasTrash()) {
		fileUtils.moveToTrash(files);
	} else {
		// delete
		for(File file:files) {
			org.apache.commons.io.FileUtils.forceDelete(file);
		}
	}
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:12,代码来源:DesktopProject.java


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