当前位置: 首页>>代码示例>>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;未经允许,请勿转载。