想通过bt-cli下载种子。我试图将bt-cli作为bt parent的模块启动,并且将bt-cli-demo作为项目启动,但是我还是将java.nio.file.AccessDeniedException获取到临时文件。
我一直尝试通过Intellij Idea和Shell进行同样的问题。
还尝试使用-f和-m键(链接到项目和键描述https://github.com/atomashpolskiy/bt)来下载
我总是遇到相同的异常: exception screen
也许我必须为临时文件更改文件夹,但是我不知道要这么做
代码:
public static void main(String[] args) throws IOException {
Options options;
try {
options = Options.parse(args);
} catch (OptionException e) {
Options.printHelp(System.out);
return;
}
configureLogging(options.getLogLevel());
configureSecurity();
registerLog4jShutdownHook();
CliClient client = new CliClient(options);
client.start();
}
我从shell获得的所有参数,api对其进行解析,并根据收入参数创建配置。然后开始。
外壳参数:
static {
parser = new OptionParser() {
{
acceptsAll(Arrays.asList("?", "h", "help")).isForHelp();
}
};
metainfoFileOptionSpec = parser.acceptsAll(Arrays.asList("f", "file"), "Torrent metainfo file")
.withRequiredArg().ofType(File.class);
magnetUriOptionSpec = parser.acceptsAll(Arrays.asList("m", "magnet"), "Magnet URI")
.withRequiredArg().ofType(String.class);
targetDirectoryOptionSpec = parser.acceptsAll(Arrays.asList("d", "dir"), "Target download location")
.withRequiredArg().ofType(File.class)
.required();
shouldSeedOptionSpec = parser.acceptsAll(Arrays.asList("s", "seed"), "Continue to seed when download is complete");
sequentialOptionSpec = parser.acceptsAll(Arrays.asList("S", "sequential"), "Download sequentially");
enforceEncryptionOptionSpec = parser.acceptsAll(Arrays.asList("e", "encrypted"), "Enforce encryption for all connections");
verboseOptionSpec = parser.acceptsAll(Arrays.asList("v", "verbose"), "Enable more verbose logging");
traceOptionSpec = parser.accepts("trace", "Enable trace logging");
inetAddressOptionSpec = parser.acceptsAll(Arrays.asList("i", "inetaddr"), "Use specific network address (possible values include IP address literal or hostname)")
.withRequiredArg().ofType(String.class);
torrentPortOptionSpec = parser.acceptsAll(Arrays.asList("p", "port"), "Listen on specific port for incoming connections")
.withRequiredArg().ofType(Integer.class);
dhtPortOptionSpec = parser.accepts("dhtport", "Listen on specific port for DHT messages")
.withRequiredArg().ofType(Integer.class);
shouldDownloadAllFiles = parser.acceptsAll(Arrays.asList("a", "all"), "Download all files (file selection will be disabled)");
}
/**
* @throws OptionException
*/
public static Options parse(String... args) {
OptionSet opts = parser.parse(args);
return new Options(
opts.valueOf(metainfoFileOptionSpec),
opts.valueOf(magnetUriOptionSpec),
opts.valueOf(targetDirectoryOptionSpec),
opts.has(shouldSeedOptionSpec),
opts.has(sequentialOptionSpec),
opts.has(enforceEncryptionOptionSpec),
opts.has(verboseOptionSpec),
opts.has(traceOptionSpec),
opts.valueOf(inetAddressOptionSpec),
opts.valueOf(torrentPortOptionSpec),
opts.valueOf(dhtPortOptionSpec),
opts.has(shouldDownloadAllFiles));
}
答案 0 :(得分:1)
AccessDeniedException可能意味着很多事情。 documentation说:“文件系统操作通常由于文件许可或其他访问检查而被拒绝”,我会注意“其他”一词。