我想为枚举构造函数创建一个 Path 实例:
/** Temporary paths. */
public enum PATHS {
/** First temporary directory. */
PATH1(Files.createTempDirectory(new StringBuilder("tnk").append(File.separator).append("path1")
.toString())),
/** Second temporary directory. */
PATH2(Files.createTempDirectory(new StringBuilder("tnk").append(File.separator).append("path2")
.toString()));
/** {@link Path} reference. */
final Path mPath;
/**
* Constructor.
*
* @param pPath
* {@link Path} reference
*/
PATHS(final Path pPath) {
mPath = pPath;
}
/**
* Get {@link File} associated with the path.
*
* @return {@link File} reference
*/
public File getFile() {
return mPath.toFile();
}
}
Files.createTempDirectory(String, FilleAttribute<?> atts)
抛出检查异常(IOException),但我如何捕获或抛出异常,或者更准确地说,我如何处理异常?似乎是一个转储问题,但我现在不知道。