首页 文章

java.nio.file.AccessDeniedException到〜/ AppData \ Local \ Temp \ unlink-test12695598880278433589.tmp文件bt-cli api

提问于
浏览
-1

想通过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));
}

1 回答

  • 0

    AccessDeniedException可能意味着很多东西 . documentation说:"a file system operation is denied, typically due to a file permission or other access check",我会注意"other"这个词 .

相关问题