Search in sources :

Example 11 with CharSource

use of com.google.common.io.CharSource in project beam by apache.

the class ZipFilesTest method testAsCharSource.

@Test
public void testAsCharSource() throws Exception {
    File zipDir = new File(tmpDir, "zip");
    assertTrue(zipDir.mkdirs());
    createFileWithContents(zipDir, "myTextFile.txt", "Simple Text");
    ZipFiles.zipDirectory(tmpDir, zipFile);
    try (ZipFile zip = new ZipFile(zipFile)) {
        ZipEntry entry = zip.getEntry("zip/myTextFile.txt");
        CharSource charSource = ZipFiles.asCharSource(zip, entry, StandardCharsets.UTF_8);
        assertEquals("Simple Text", charSource.read());
    }
}
Also used : CharSource(com.google.common.io.CharSource) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 12 with CharSource

use of com.google.common.io.CharSource in project GeoGig by boundlessgeo.

the class ConsoleResourceResource method getLimitedOutput.

private StringBuilder getLimitedOutput(FileBackedOutputStream out, final int limit) throws IOException {
    CharSource charSource = out.asByteSource().asCharSource(Charsets.UTF_8);
    BufferedReader reader = charSource.openBufferedStream();
    final StringBuilder output = new StringBuilder();
    int count = 0;
    String line;
    while ((line = reader.readLine()) != null) {
        output.append(line).append('\n');
        count += line.length();
        if (count >= limit) {
            output.append("\nNote: output limited to ").append(count).append(" characters. Run config web.console.limit <newlimit> to change the current ").append(limit).append(" soft limit.");
            break;
        }
    }
    return output;
}
Also used : CharSource(com.google.common.io.CharSource) BufferedReader(java.io.BufferedReader)

Example 13 with CharSource

use of com.google.common.io.CharSource in project GeoGig by boundlessgeo.

the class GlobalState method runAndParseCommand.

public static List<String> runAndParseCommand(boolean failFast, String... command) throws Exception {
    runCommand(failFast, command);
    CharSource reader = CharSource.wrap(stdOut.toString(Charsets.UTF_8.name()));
    ImmutableList<String> lines = reader.readLines();
    return lines;
}
Also used : CharSource(com.google.common.io.CharSource)

Aggregations

CharSource (com.google.common.io.CharSource)13 IncrementalIndex (io.druid.segment.incremental.IncrementalIndex)5 IncrementalIndexSegment (io.druid.segment.IncrementalIndexSegment)4 OnheapIncrementalIndex (io.druid.segment.incremental.OnheapIncrementalIndex)4 File (java.io.File)4 IOException (java.io.IOException)3 Splitter (com.google.common.base.Splitter)2 StringInputRowParser (io.druid.data.input.impl.StringInputRowParser)2 Segment (io.druid.segment.Segment)2 DataSegment (io.druid.timeline.DataSegment)2 VersionedIntervalTimeline (io.druid.timeline.VersionedIntervalTimeline)2 SingleElementPartitionChunk (io.druid.timeline.partition.SingleElementPartitionChunk)2 FileInputStream (java.io.FileInputStream)2 URL (java.net.URL)2 Interval (org.joda.time.Interval)2 BeforeClass (org.junit.BeforeClass)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Injector (com.google.inject.Injector)1 DelimitedParseSpec (io.druid.data.input.impl.DelimitedParseSpec)1 DimensionsSpec (io.druid.data.input.impl.DimensionsSpec)1