Example usage for java.io SequenceInputStream SequenceInputStream

List of usage examples for java.io SequenceInputStream SequenceInputStream

Introduction

In this page you can find the example usage for java.io SequenceInputStream SequenceInputStream.

Prototype

public SequenceInputStream(Enumeration<? extends InputStream> e) 

Source Link

Document

Initializes a newly created SequenceInputStream by remembering the argument, which must be an Enumeration that produces objects whose run-time type is InputStream.

Usage

From source file:Main.java

public static void main(String[] args) throws IOException {

    Vector theStreams = new Vector();

    for (int i = 0; i < args.length; i++) {
        FileInputStream fin = new FileInputStream(args[i]);
        theStreams.addElement(fin);/* www .j a v a  2 s  . c  om*/
    }

    InputStream in = new SequenceInputStream(theStreams.elements());
    for (int i = in.read(); i != -1; i = in.read()) {
        System.out.write(i);
    }
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Vector v = new Vector(3);
    v.add(new FileInputStream("/a/b"));
    v.add(new FileInputStream("yourfile.bar"));
    v.add(new FileInputStream("/yourfile.txt"));

    Enumeration e = v.elements();
    SequenceInputStream sis = new SequenceInputStream(e);
    InputStreamReader isr = new InputStreamReader(sis);
    BufferedReader br = new BufferedReader(isr);
    String line;/*from ww  w  .  j  a v a2  s  .  c  o  m*/
    while ((line = br.readLine()) != null) {
        System.out.println(line);
    }
    br.close();
}

From source file:Sequence.java

public static void main(String args[]) throws IOException {
    Vector v = new Vector(3);
    v.add(new FileInputStream("/etc/motd"));
    v.add(new FileInputStream("foo.bar"));
    v.add(new FileInputStream("/temp/john.txt"));
    Enumeration e = v.elements();
    SequenceInputStream sis = new SequenceInputStream(e);
    InputStreamReader isr = new InputStreamReader(sis);
    BufferedReader br = new BufferedReader(isr);
    String line;//from   w w w .j  av a2  s.  c o  m
    while ((line = br.readLine()) != null) {
        System.out.println(line);
    }
    br.close();
}

From source file:InputStreamEnumerator.java

public static void main(String args[]) throws IOException {

    int c;/*from w ww.j a  v a 2  s .  com*/
    Vector<String> files = new Vector<String>();

    files.addElement("c:\\autoexec.bat");
    files.addElement("c:\\config.sys");
    InputStreamEnumerator e = new InputStreamEnumerator(files);
    InputStream input = new SequenceInputStream(e);

    while ((c = input.read()) != -1) {
        System.out.print((char) c);
    }

    input.close();
}

From source file:pt.webdetails.cdf.dd.packager.Concatenate.java

public static InputStream concat(File[] files) {
    ListOfFiles mylist = new ListOfFiles(files);

    return new SequenceInputStream(mylist);
}

From source file:pt.webdetails.cpf.packager.dependencies.CssMinifiedDependency.java

@Override
protected InputStream minifyPackage(Iterable<FileDependency> inputFiles) {
    return new SequenceInputStream(new CssReplacementStreamEnumeration(inputFiles.iterator()));
}

From source file:pt.webdetails.cpf.packager.dependencies.JsMinifiedDependency.java

@Override
protected InputStream minifyPackage(Iterable<FileDependency> inputFiles) {
    return new SequenceInputStream(new JsMinificationEnumeration(inputFiles.iterator()));
}

From source file:org.mule.modules.hdfs.automation.testcases.AppendTestCases.java

@Category({ RegressionTests.class })
@Test// w w w  . j  av  a2s .c o  m
public void testAppend() {

    Vector<InputStream> inputStreams = new Vector<InputStream>();
    inputStreams.add((InputStream) getTestRunMessageValue("payloadRef"));

    InputStream inputStreamToAppend = getBeanFromContext("randomInputStream");
    inputStreams.add(inputStreamToAppend);
    upsertOnTestRunMessage("payloadRef", inputStreamToAppend);

    SequenceInputStream inputStreamsSequence = new SequenceInputStream(
            (Enumeration<InputStream>) inputStreams.elements());

    try {
        runFlowAndGetPayload("append");
        IOUtils.contentEquals(inputStreamsSequence, (InputStream) runFlowAndGetPayload("read"));

    } catch (Exception e) {
        fail(ConnectorTestUtils.getStackTrace(e));
    }

}

From source file:org.mule.modules.hdfs.automation.functional.AppendTestCases.java

@Test
public void testAppend() throws Exception {
    Vector<InputStream> inputStreams = new Vector<InputStream>();
    inputStreams.add(new ByteArrayInputStream(initialWrittenData));

    byte[] inputStreamToAppend = TestDataBuilder.payloadForAppend();
    inputStreams.add(new ByteArrayInputStream(inputStreamToAppend));

    SequenceInputStream inputStreamsSequence = new SequenceInputStream(inputStreams.elements());

    getConnector().append(MYFILE_PATH, 4096, new ByteArrayInputStream(inputStreamToAppend));
    InputStream payload = getConnector().readOperation(MYFILE_PATH, 4096);
    Assert.assertThat(IOUtils.contentEquals(inputStreamsSequence, payload), is(true));
}

From source file:com.github.benmanes.caffeine.cache.simulator.parser.AbstractTraceReader.java

/** Returns the input stream of the trace data. */
protected InputStream readFiles() throws IOException {
    List<InputStream> inputs = new ArrayList<>(filePaths.size());
    for (String filePath : filePaths) {
        inputs.add(readFile(filePath));//w  w  w  . j a v  a  2  s  . c om
    }
    return new SequenceInputStream(Collections.enumeration(inputs));
}