【发布时间】:2019-02-14 07:08:42
【问题描述】:
想通过 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 解析它并根据收入参数创建配置。然后就开始了。
shell 参数:
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));
}
【问题讨论】:
-
所以您的问题中没有任何内容与您编写的代码有关,而是关于操作系统权限而不是编程?
-
我使用了自述文件中的示例。好的,我要编辑问题
-
但你说得对,这与操作系统问题更相关,我询问了该领域的帮助。
标签: java exception access-denied temp torrent