當前位置: 首頁>>代碼示例>>Java>>正文


Java SequenceInputStream類代碼示例

本文整理匯總了Java中java.io.SequenceInputStream的典型用法代碼示例。如果您正苦於以下問題:Java SequenceInputStream類的具體用法?Java SequenceInputStream怎麽用?Java SequenceInputStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SequenceInputStream類屬於java.io包,在下文中一共展示了SequenceInputStream類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.io.SequenceInputStream; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
	// SequenceInputStream(InputStream s1, InputStream s2)
	// 需求:把ByteArrayStreamDemo.java和DataStreamDemo.java的內容複製到Copy.java中
	InputStream s1 = new FileInputStream("ByteArrayStreamDemo.java");
	InputStream s2 = new FileInputStream("DataStreamDemo.java");
	SequenceInputStream sis = new SequenceInputStream(s1, s2);
	BufferedOutputStream bos = new BufferedOutputStream(
			new FileOutputStream("Copy.java"));

	// 如何寫讀寫呢,其實很簡單,你就按照以前怎麽讀寫,現在還是怎麽讀寫
	byte[] bys = new byte[1024];
	int len = 0;
	while ((len = sis.read(bys)) != -1) {
		bos.write(bys, 0, len);
	}

	bos.close();
	sis.close();
}
 
開發者ID:aircjm,項目名稱:JavaSeStudy,代碼行數:20,代碼來源:SequenceInputStreamDemo.java

示例2: toBufferedInputStream

import java.io.SequenceInputStream; //導入依賴的package包/類
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:27,代碼來源:ByteArrayOutputStream.java

示例3: getContent

import java.io.SequenceInputStream; //導入依賴的package包/類
@Override
public Optional<InputStream> getContent(final IRI identifier, final List<Range<Integer>> ranges) {
    requireNonNull(ranges, "Byte ranges may not be null");
    return getFileFromIdentifier(identifier).map(file -> {
        try {
            if (ranges.isEmpty()) {
                return new FileInputStream(file);
            } else {
                final List<InputStream> iss = new ArrayList<>();
                for (final Range<Integer> r : ranges) {
                    final InputStream input = new FileInputStream(file);
                    final long skipped = input.skip(r.getMinimum());
                    LOGGER.debug("Skipped {} bytes", skipped);
                    iss.add(new BoundedInputStream(input, r.getMaximum() - r.getMinimum()));
                }
                return new SequenceInputStream(asEnumeration(iss.iterator()));
            }
        } catch (final IOException ex) {
            throw new UncheckedIOException(ex);
        }
    });
}
 
開發者ID:trellis-ldp,項目名稱:trellis,代碼行數:23,代碼來源:FileBasedBinaryService.java

示例4: toBufferedInputStream

import java.io.SequenceInputStream; //導入依賴的package包/類
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since Commons IO 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
 
開發者ID:fesch,項目名稱:Moenagade,代碼行數:27,代碼來源:ByteArrayOutputStream.java

示例5: toBufferedInputStream

import java.io.SequenceInputStream; //導入依賴的package包/類
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * 
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.0
 */
private InputStream toBufferedInputStream() {
    int remaining = count;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:27,代碼來源:ByteArrayOutputStream.java

示例6: upload

import java.io.SequenceInputStream; //導入依賴的package包/類
/**
 * Upload a file of quote in add mode.
 * 
 * @param subscription
 *            The subscription identifier, will be used to filter the locations
 *            from the associated provider.
 * @param uploadedFile
 *            Instance entries files to import. Currently support only CSV
 *            format.
 * @param columns
 *            the CSV header names.
 * @param term
 *            The default {@link ProvInstancePriceTerm} used when no one is
 *            defined in the CSV line
 * @param ramMultiplier
 *            The multiplier for imported RAM values. Default is 1.
 * @param encoding
 *            CSV encoding. Default is UTF-8.
 * @throws IOException
 *             When the CSV stream cannot be written.
 */
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("{subscription:\\d+}/upload")
public void upload(@PathParam("subscription") final int subscription, @Multipart(value = "csv-file") final InputStream uploadedFile,
		@Multipart(value = "columns", required = false) final String[] columns,
		@Multipart(value = "term", required = false) final String term,
		@Multipart(value = "memoryUnit", required = false) final Integer ramMultiplier,
		@Multipart(value = "encoding", required = false) final String encoding) throws IOException {
	subscriptionResource.checkVisibleSubscription(subscription).getNode().getId();

	// Check column's name validity
	final String[] sanitizeColumns = ArrayUtils.isEmpty(columns) ? DEFAULT_COLUMNS : columns;
	checkHeaders(ACCEPTED_COLUMNS, sanitizeColumns);

	// Build CSV header from array
	final String csvHeaders = StringUtils.chop(ArrayUtils.toString(sanitizeColumns)).substring(1).replace(',', ';') + "\n";

	// Build entries
	final String safeEncoding = ObjectUtils.defaultIfNull(encoding, StandardCharsets.UTF_8.name());
	csvForBean
			.toBean(InstanceUpload.class, new InputStreamReader(
					new SequenceInputStream(new ByteArrayInputStream(csvHeaders.getBytes(safeEncoding)), uploadedFile), safeEncoding))
			.stream().filter(Objects::nonNull).forEach(i -> persist(i, subscription, term, ramMultiplier));
}
 
開發者ID:ligoj,項目名稱:plugin-prov,代碼行數:46,代碼來源:ProvQuoteInstanceResource.java

示例7: getInputStream

import java.io.SequenceInputStream; //導入依賴的package包/類
@Override
public InputStream getInputStream() throws IOException
{
  boolean hasseparator = (_separator!=null);
  InputStream[] streams;
  if(hasseparator)
  {
    streams = new InputStream[(_connections.length *2)-1];
  }
  else
  {
    streams = new InputStream[_connections.length];
  }

  for (int i=0, len=_connections.length, sublen = len -1, streamCounter = 0; i < len; i++, streamCounter++)
  {
    streams[streamCounter] = _connections[i].getInputStream();

    //Add the separator if needed
    if(hasseparator && (i < sublen))
    {
      streams[++streamCounter] = new SeparatorInputStream(_separator);
    }
  }
  return new SequenceInputStream(new ArrayEnumeration<InputStream>(streams));
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:27,代碼來源:AggregatingResourceLoader.java

示例8: mergeResourceWithPrefixes

import java.io.SequenceInputStream; //導入依賴的package包/類
public static Model mergeResourceWithPrefixes(InputStream inputStreamPrefixes,
    InputStream inputStreamData) throws IOException {
  final Resource mergedDataResource =
      new InputStreamResource(new SequenceInputStream(inputStreamPrefixes, inputStreamData));
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

  RDFWriter turtleWriter = Rio.createWriter(RDFFormat.TURTLE, byteArrayOutputStream);
  RDFParser trigParser = Rio.createParser(RDFFormat.TRIG);
  trigParser.setRDFHandler(turtleWriter);
  trigParser.parse(mergedDataResource.getInputStream(), "");

  Model result = Rio.parse(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), "",
      RDFFormat.TURTLE);

  byteArrayOutputStream.close();
  inputStreamData.close();
  return result;
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:19,代碼來源:RdfModelTransformer.java

示例9: validate

import java.io.SequenceInputStream; //導入依賴的package包/類
private void validate(List<InputStream> configurationStreams) {
  if (!configurationStreams.isEmpty()) {
    try (InputStream stream =
        new SequenceInputStream(Collections.enumeration(configurationStreams))) {
      final ValidationReport report =
          shaclValidator.validate(RdfModelTransformer.getModel(stream),
              RdfModelTransformer.getModel(elmoShapes.getInputStream()));
      if (!report.isValid()) {
        throw new ShaclValidationException(report.printReport());
      }
    } catch (IOException ex) {
      throw new ShaclValidationException("Configuration files could not be read.", ex);
    }
  } else {
    LOG.error("Found no configuration files");
  }
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:18,代碼來源:FileConfigurationBackend.java

示例10: getIndex

import java.io.SequenceInputStream; //導入依賴的package包/類
/**
 * Get Swagger UI main index page.
 *
 * @return 200 OK
 * @throws IOException if unable to get index resource
 */
@GET
@Path("index.html")
public Response getIndex() throws IOException {
    InputStream stream = getClass().getClassLoader().getResourceAsStream(DOCS + "index.html");
    nullIsNotFound(stream, "index.html not found");

    String index = new String(toByteArray(stream));

    int p1s = split(index, 0, INJECT_START);
    int p1e = split(index, p1s, INJECT_END);
    int p2s = split(index, p1e, null);

    StreamEnumeration streams =
            new StreamEnumeration(of(stream(index, 0, p1s),
                                     includeOptions(get(ApiDocService.class)),
                                     stream(index, p1e, p2s)));

    return ok(new SequenceInputStream(streams))
            .header(CONTENT_TYPE, TEXT_HTML).build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:27,代碼來源:ApiDocResource.java

示例11: getMainModule

import java.io.SequenceInputStream; //導入依賴的package包/類
@GET
@Produces(SCRIPT)
public Response getMainModule() throws IOException {
    UiExtensionService service = get(UiExtensionService.class);
    InputStream jsTemplate = getClass().getClassLoader().getResourceAsStream(MAIN_JS);
    String js = new String(toByteArray(jsTemplate));

    int p1s = split(js, 0, INJECT_VIEW_IDS_START) - INJECT_VIEW_IDS_START.length();
    int p1e = split(js, 0, INJECT_VIEW_IDS_END);
    int p2s = split(js, p1e, null);

    StreamEnumeration streams =
            new StreamEnumeration(of(stream(js, 0, p1s),
                                     includeViewIds(service),
                                     stream(js, p1e, p2s)));

    return Response.ok(new SequenceInputStream(streams)).build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:19,代碼來源:MainModuleResource.java

示例12: getNavigation

import java.io.SequenceInputStream; //導入依賴的package包/類
@GET
@Produces(MediaType.TEXT_HTML)
public Response getNavigation() throws IOException {
    UiExtensionService service = get(UiExtensionService.class);
    InputStream navTemplate =
            getClass().getClassLoader().getResourceAsStream(NAV_HTML);
    String html = new String(toByteArray(navTemplate));

    int p1s = split(html, 0, INJECT_VIEW_ITEMS_START);
    int p1e = split(html, 0, INJECT_VIEW_ITEMS_END);
    int p2s = split(html, p1e, null);

    StreamEnumeration streams =
            new StreamEnumeration(of(stream(html, 0, p1s),
                                     includeNavItems(service),
                                     stream(html, p1e, p2s)));

    return Response.ok(new SequenceInputStream(streams)).build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:20,代碼來源:MainNavResource.java

示例13: buildTestData

import java.io.SequenceInputStream; //導入依賴的package包/類
private void buildTestData() {
	List<InputStream> testDataInputStreams = new ArrayList<InputStream>();
	
	for(String testFile: testFiles) {
		/** start / is required for getResourceAsStream method otherwise files is not loaded.**/
		testFile = "/"+testFile;
		testDataInputStreams.add(TestData.class.getResourceAsStream(testFile));
		/** A new line character is added otherwise two files are not mearge properly and yaml parser gives error **/
		testDataInputStreams.add(new ByteArrayInputStream("\n".getBytes()));
	}
	
	SequenceInputStream SequenceInputStream = new SequenceInputStream(Collections.enumeration(testDataInputStreams));
	//System.out.print(convertToString(SequenceInputStream));

	try {
		Map testData = yamlMapper.readValue(SequenceInputStream, Map.class);
		this.dataJsonPath = JsonPath.given(jsonMapper.writeValueAsString(testData));
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:ERS-HCL,項目名稱:rest-yaml-test,代碼行數:22,代碼來源:TestData.java

示例14: inputStreamXmlEncapsulate

import java.io.SequenceInputStream; //導入依賴的package包/類
/**
 * Take a non XML section and make it XML just by adding a open and close
 * Root element
 * 
 * 
 * @param stream
 *            InputStream to encapsulate in xml
 * @return InputStream in XML format
 */
public InputStream inputStreamXmlEncapsulate(InputStream stream) {
	String frontNode = "<Root>";
	String endNode = "</Root>";

	String sectionData = "";
	try {
		sectionData = IOUtils.toString(stream, "UTF-8");
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	String escapedXml = StringEscapeUtils.escapeXml(sectionData);

	List<InputStream> xmlStreamList = Arrays.asList(new ByteArrayInputStream(frontNode.getBytes()),
			(InputStream) new ByteArrayInputStream(escapedXml.getBytes()),
			new ByteArrayInputStream(endNode.getBytes()));
	InputStream endStream = new SequenceInputStream(Collections.enumeration(xmlStreamList));

	return endStream;
}
 
開發者ID:ibm-datapower,項目名稱:ertool,代碼行數:31,代碼來源:ERFramework.java

示例15: toInputStream

import java.io.SequenceInputStream; //導入依賴的package包/類
/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 *
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 * @since 2.5
 */
public synchronized InputStream toInputStream() {
  int remaining = count;
  if (remaining == 0) {
    return new ClosedInputStream();
  }
  final List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
  for (final byte[] buf : buffers) {
    final int c = Math.min(buf.length, remaining);
    list.add(new ByteArrayInputStream(buf, 0, c));
    remaining -= c;
    if (remaining == 0) {
      break;
    }
  }
  reuseBuffers = false;
  return new SequenceInputStream(Collections.enumeration(list));
}
 
開發者ID:jaredrummler,項目名稱:TrueTypeParser,代碼行數:28,代碼來源:ByteArrayOutputStream.java


注:本文中的java.io.SequenceInputStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。