• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TeeInput类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.cactoos.io.TeeInput的典型用法代码示例。如果您正苦于以下问题:Java TeeInput类的具体用法?Java TeeInput怎么用?Java TeeInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TeeInput类属于org.cactoos.io包,在下文中一共展示了TeeInput类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: export

import org.cactoos.io.TeeInput; //导入依赖的package包/类
@Override
public File export() throws IOException, URISyntaxException {
    final File file = File.createTempFile("report", ".zip");
    new LengthOf(
        new TeeInput(
            new InputOf(
                new URI(
                    this.req
                        .fetch()
                        .as(RestResponse.class)
                        .assertStatus(HttpURLConnection.HTTP_MOVED_TEMP)
                        .headers()
                        .get(HttpHeaders.LOCATION)
                        .get(0)
                )
            ),
            new OutputTo(
                file
            )
        )
    ).value();
    return file;
}
 
开发者ID:smallcreep,项目名称:streamrail-api-client,代码行数:24,代码来源:ExportReport.java


示例2: testSimpleCompilation

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * Main can print a simple text.
 * @throws Exception If some problem inside
 */
public void testSimpleCompilation() throws Exception {
    final CompileMojo mojo = new CompileMojo();
    this.temp.create();
    final File src = this.temp.newFolder();
    this.setVariableValueToObject(mojo, "sourceDirectory", src);
    new LengthOf(
        new TeeInput(
            new InputOf(
                "type Pixel:\n  Pixel moveTo(Integer x, Integer y)"
            ),
            new OutputTo(new File(src, "main.eo"))
        )
    ).value();
    final File target = this.temp.newFolder();
    this.setVariableValueToObject(mojo, "targetDirectory", target);
    this.setVariableValueToObject(mojo, "project", new MavenProjectStub());
    mojo.execute();
    MatcherAssert.assertThat(
        new File(target, "Pixel.java").exists(),
        Matchers.is(true)
    );
}
 
开发者ID:yegor256,项目名称:eo,代码行数:27,代码来源:CompileMojoTest.java


示例3: findsWithXpathWithCustomNamespace

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * XMLDocument can find with XPath with custom namespaces.
 * @throws Exception If something goes wrong inside
 */
@Test
public void findsWithXpathWithCustomNamespace() throws Exception {
    final File file = new File(Files.createTempDir(), "x.xml");
    new LengthOf(
        new TeeInput(
            "<a xmlns='urn:foo'><b>\u0433!</b></a>",
            file
        )
    ).value();
    final XML doc = new XMLDocument(file).registerNs("f", "urn:foo");
    MatcherAssert.assertThat(
        doc.nodes("/f:a/f:b[.='\u0433!']"),
        Matchers.hasSize(1)
    );
    MatcherAssert.assertThat(
        doc.xpath("//f:b/text()").get(0),
        Matchers.equalTo("\u0433!")
    );
}
 
开发者ID:jcabi,项目名称:jcabi-xml,代码行数:24,代码来源:XMLDocumentTest.java


示例4: rendersSvgBadge

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * TkBadge can render an SVG badge.
 * @throws Exception If some problem inside
 */
@Test
public void rendersSvgBadge() throws Exception {
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(
            new TextOf(
                new TeeInput(
                    new InputOf(
                        new RsPrint(
                            new TkBadge(new FakeBase()).act(
                                new RqFake(
                                    new ListOf<>(
                                        "GET /?u=http://www.yegor256.com",
                                        "Host: www.rehttp.net"
                                    ),
                                    ""
                                )
                            )
                        ).printBody()
                    ),
                    new OutputTo(new File("target/rehttp.svg"))
                )
            ).asString()
        ),
        XhtmlMatchers.hasXPath("/svg:svg//svg:path")
    );
}
 
开发者ID:yegor256,项目名称:rehttp,代码行数:31,代码来源:TkBadgeTest.java


示例5: save

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * Save report.
 * @param target Target dir
 * @throws IOException If fails
 */
public void save(final Path target) throws IOException {
    final XML xml = new StrictXML(
        new ReportWithStatistics(
            new IoCheckedScalar<>(
                new Reduced<>(
                    this.xml(),
                    (doc, xsl) -> xsl.transform(doc),
                    this.post
                )
            ).value()
        ),
        Report.SCHEMA
    );
    new LengthOf(
        new TeeInput(
            xml.toString(),
            target.resolve(
                String.format("%s.xml", this.metric)
            )
        )
    ).intValue();
    new LengthOf(
        new TeeInput(
            Report.STYLESHEET.transform(xml).toString(),
            target.resolve(
                String.format("%s.html", this.metric)
            )
        )
    ).intValue();
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:36,代码来源:Report.java


示例6: copy

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * Copy resource.
 * @param name The name of resource
 * @throws IOException If fails
 */
private void copy(final String name) throws IOException {
    new IoCheckedScalar<>(
        new LengthOf(
            new TeeInput(
                new ResourceOf(String.format("org/jpeek/%s", name)),
                this.output.resolve(name)
            )
        )
    ).value();
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:16,代码来源:App.java


示例7: save

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * Save file.
 * @param data Content
 * @param name The name of destination file
 * @throws IOException If fails
 */
private void save(final String data, final String name) throws IOException {
    new IoCheckedScalar<>(
        new LengthOf(
            new TeeInput(
                data,
                this.output.resolve(name)
            )
        )
    ).value();
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:17,代码来源:App.java


示例8: start

import org.cactoos.io.TeeInput; //导入依赖的package包/类
@Override
public void start(final Environment env) throws IOException {
    new LengthOf(
        new TeeInput(this.command, new OutputTo(this.output))
    ).value();
    this.callback.onExit(0);
}
 
开发者ID:jcabi,项目名称:jcabi-ssh,代码行数:8,代码来源:MkCommand.java


示例9: readsFileAsText

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * TextResource should be able to read files as text.
 * @throws Exception If something goes wrong.
 */
@Test
public void readsFileAsText() throws Exception {
    final String text = "<a xmlns='urn:foo'><b>\u0433!</b></a>";
    final File file = new File(Files.createTempDir(), "dummy.xml");
    new LengthOf(new TeeInput(text, file)).value();
    MatcherAssert.assertThat(
        new TextResource(file).toString(),
        Matchers.is(text)
    );
}
 
开发者ID:jcabi,项目名称:jcabi-xml,代码行数:15,代码来源:TextResourceTest.java


示例10: sourcesResolvedFromDir

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * FileSources can resolve resource.
 * @throws Exception If something goes wrong inside
 */
@Test
public void sourcesResolvedFromDir() throws Exception {
    final File file = new File(Files.createTempDir(), "dummy.xml");
    new LengthOf(new TeeInput("test", file)).value();
    MatcherAssert.assertThat(
        new FileSources().resolve(file.getAbsolutePath(), null),
        Matchers.notNullValue()
    );
}
 
开发者ID:jcabi,项目名称:jcabi-xml,代码行数:14,代码来源:FileSourcesTest.java


示例11: apply

import org.cactoos.io.TeeInput; //导入依赖的package包/类
@Override
public Func<String, Response> apply(final String group,
    final String artifact) throws IOException {
    final String grp = group.replace(".", "/");
    final Path input = this.sources.resolve(grp).resolve(artifact);
    if (Files.exists(input)) {
        throw new IllegalStateException(
            String.format(
                "The input directory for %s:%s already exists: %s",
                group, artifact, input
            )
        );
    }
    final String version = new XMLDocument(
        new TextOf(
            new URL(
                String.format(
                    // @checkstyle LineLength (1 line)
                    "http://repo1.maven.org/maven2/%s/%s/maven-metadata.xml",
                    grp, artifact
                )
            )
        ).asString()
    ).xpath("/metadata/versioning/latest/text()").get(0);
    final String name = String.format("%s-%s.jar", artifact, version);
    new IoCheckedScalar<>(
        new LengthOf(
            new TeeInput(
                new URL(
                    String.format(
                        "http://repo1.maven.org/maven2/%s/%s/%s/%s",
                        grp, artifact, version, name
                    )
                ),
                input.resolve(name)
            )
        )
    ).value();
    try {
        final File none = new File("/dev/null");
        final int exit = new ProcessBuilder()
            .redirectOutput(ProcessBuilder.Redirect.to(none))
            .redirectInput(ProcessBuilder.Redirect.from(none))
            .redirectError(ProcessBuilder.Redirect.to(none))
            .directory(input.toFile())
            .command("unzip", name)
            .start()
            .waitFor();
        if (exit != 0) {
            throw new IllegalStateException(
                String.format(
                    "Failed to unzip %s:%s archive, exit code %d",
                    group, artifact, exit
                )
            );
        }
    } catch (final InterruptedException ex) {
        Thread.currentThread().interrupt();
        throw new IllegalStateException(ex);
    }
    final Path output = this.target.resolve(grp).resolve(artifact);
    if (Files.exists(output)) {
        throw new IllegalStateException(
            String.format(
                "The output directory for %s:%s already exists: %s",
                group, artifact, output
            )
        );
    }
    new App(input, output).analyze();
    synchronized (this.sources) {
        new Results().add(String.format("%s:%s", group, artifact), output);
        new Mistakes().add(output);
        new Sigmas().add(output);
    }
    return new TypedPages(new Pages(output));
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:78,代码来源:Reports.java


示例12: files

import org.cactoos.io.TeeInput; //导入依赖的package包/类
@Override
public Iterable<Path> files() throws IOException {
    final Path temp = Files.createTempDirectory("jpeek");
    final Iterable<String> sources = new Mapped<>(
        cls -> String.format("%s.java", cls),
        this.classes
    );
    new IoCheckedScalar<>(
        new And(
            java -> {
                new LengthOf(
                    new TeeInput(
                        new ResourceOf(
                            String.format("org/jpeek/samples/%s", java)
                        ),
                        temp.resolve(java)
                    )
                ).value();
            },
            sources
        )
    ).value();
    if (sources.iterator().hasNext()) {
        final int exit;
        try {
            exit = new ProcessBuilder()
                .redirectOutput(ProcessBuilder.Redirect.INHERIT)
                .redirectInput(ProcessBuilder.Redirect.INHERIT)
                .redirectError(ProcessBuilder.Redirect.INHERIT)
                .directory(temp.toFile())
                .command(
                    new ListOf<>(
                        new Joined<String>(
                            new ListOf<>("javac"),
                            sources
                        )
                    )
                )
                .start()
                .waitFor();
        } catch (final InterruptedException ex) {
            Thread.currentThread().interrupt();
            throw new IllegalStateException(ex);
        }
        if (exit != 0) {
            throw new IllegalStateException(
                String.format("javac failed with exit code %d", exit)
            );
        }
    }
    return new DefaultBase(temp).files();
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:53,代码来源:FakeBase.java


示例13: compile

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * Compile it to Java and save.
 * @throws IOException If fails
 */
public void compile() throws IOException {
    final String[] lines = new TextOf(this.input).asString().split("\n");
    final ANTLRErrorListener errors = new BaseErrorListener() {
        // @checkstyle ParameterNumberCheck (10 lines)
        @Override
        public void syntaxError(final Recognizer<?, ?> recognizer,
            final Object symbol, final int line,
            final int position, final String msg,
            final RecognitionException error) {
            throw new CompileException(
                String.format(
                    "[%d:%d] %s: \"%s\"",
                    line, position, msg, lines[line - 1]
                ),
                error
            );
        }
    };
    final ProgramLexer lexer = new ProgramLexer(
        CharStreams.fromStream(this.input.stream())
    );
    lexer.removeErrorListeners();
    lexer.addErrorListener(errors);
    final ProgramParser parser = new ProgramParser(
        new CommonTokenStream(lexer)
    );
    parser.removeErrorListeners();
    parser.addErrorListener(errors);
    final Tree tree = parser.program().ret;
    new IoCheckedScalar<>(
        new And(
            tree.java().entrySet(),
            path -> {
                new LengthOf(
                    new TeeInput(
                        path.getValue(),
                        this.target.apply(path.getKey())
                    )
                ).value();
            }
        )
    ).value();
}
 
开发者ID:yegor256,项目名称:eo,代码行数:48,代码来源:Program.java


示例14: Sshd

import org.cactoos.io.TeeInput; //导入依赖的package包/类
/**
 * Ctor.
 * @param path Directory to work in
 * @throws IOException If fails
 */
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public Sshd(final File path) throws IOException {
    this.dir = path;
    final File rsa = new File(this.dir, "host_rsa_key");
    new LengthOf(
        new TeeInput(
            new ResourceOf("com/jcabi/ssh/ssh_host_rsa_key"), rsa
        )
    ).value();
    final File keys = new File(this.dir, "authorized");
    new LengthOf(
        new TeeInput(
            new ResourceOf("com/jcabi/ssh/authorized_keys"), keys
        )
    ).value();
    new VerboseProcess(
        new ProcessBuilder().command(
            "chmod", "600",
            keys.getAbsolutePath(),
            rsa.getAbsolutePath()
        )
    ).stdout();
    this.prt = Sshd.reserve();
    this.process = new ProcessBuilder().command(
        "/usr/sbin/sshd",
        "-p",
        Integer.toString(this.prt),
        "-h",
        rsa.getAbsolutePath(),
        "-D",
        "-e",
        "-o", String.format("PidFile=%s", new File(this.dir, "pid")),
        "-o", "UsePAM=no",
        "-o", String.format("AuthorizedKeysFile=%s", keys),
        "-o", "StrictModes=no"
    ).start();
    new Thread(() -> new VerboseProcess(this.process).stdout()).start();
    Runtime.getRuntime().addShutdownHook(new Thread(this::close));
    try {
        TimeUnit.SECONDS.sleep(1L);
    } catch (final InterruptedException ex) {
        Thread.currentThread().interrupt();
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:jcabi,项目名称:jcabi-ssh,代码行数:51,代码来源:Sshd.java



注:本文中的org.cactoos.io.TeeInput类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RestClientErrorHandling类代码示例发布时间:2022-05-23
下一篇:
Java PaginatedList类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap