com.google.gwt.dev.util.Util.readStreamAsString()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中com.google.gwt.dev.util.Util.readStreamAsString()方法的一些代码示例,展示了Util.readStreamAsString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.readStreamAsString()方法的具体详情如下:
包路径:com.google.gwt.dev.util.Util
类名称:Util
方法名:readStreamAsString

Util.readStreamAsString介绍

暂无

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. public Void call() throws Exception {
  2. if (mode.isEmitClasses()) {
  3. String fileName = state.type.getInternalName();
  4. if (fileName == null) {
  5. System.err.println("Got null filename from " + state.type);
  6. return null;
  7. }
  8. fileName += ".class";
  9. emitter.emit(fileName, state.contents);
  10. }
  11. if (mode.isEmitSource()) {
  12. String sourcePath = getPackagePath(state.originalType) + state.source;
  13. String destPath = getPackagePath(state.type) + state.source;
  14. if (sources.add(sourcePath) && loader.exists(sourcePath)) {
  15. String contents = Util.readStreamAsString(loader.getResourceAsStream(sourcePath));
  16. emitter.emit(destPath, new ByteArrayInputStream(Util.getBytes(contents)));
  17. }
  18. }
  19. return null;
  20. }
  21. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. @Override
  2. public InputSource resolveEntity(String publicId, String systemId) {
  3. String matchingPrefix = findMatchingPrefix(systemId);
  4. Resource resource = null;
  5. if (matchingPrefix != null) {
  6. resource =
  7. resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length()));
  8. }
  9. if (resource == null) {
  10. resource = resourceOracle.getResource(pathBase + systemId);
  11. }
  12. if (resource != null) {
  13. String content;
  14. try {
  15. InputStream resourceStream = resource.openContents();
  16. content = Util.readStreamAsString(resourceStream);
  17. } catch (IOException ex) {
  18. logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation());
  19. throw new RuntimeException(ex);
  20. }
  21. InputSource inputSource = new InputSource(new StringReader(content));
  22. inputSource.setPublicId(publicId);
  23. inputSource.setSystemId(resource.getPath());
  24. return inputSource;
  25. }
  26. /*
  27. * Let Sax find it on the interweb.
  28. */
  29. return null;
  30. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. @Override
  2. public InputSource resolveEntity(String publicId, String systemId) {
  3. String matchingPrefix = findMatchingPrefix(systemId);
  4. Resource resource = null;
  5. if (matchingPrefix != null) {
  6. resource =
  7. resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length()));
  8. }
  9. if (resource == null) {
  10. resource = resourceOracle.getResource(pathBase + systemId);
  11. }
  12. if (resource != null) {
  13. String content;
  14. try {
  15. InputStream resourceStream = resource.openContents();
  16. content = Util.readStreamAsString(resourceStream);
  17. } catch (IOException ex) {
  18. logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation());
  19. throw new RuntimeException(ex);
  20. }
  21. InputSource inputSource = new InputSource(new StringReader(content));
  22. inputSource.setPublicId(publicId);
  23. inputSource.setSystemId(resource.getPath());
  24. return inputSource;
  25. }
  26. /*
  27. * Let Sax find it on the interweb.
  28. */
  29. return null;
  30. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. public Void call() throws Exception {
  2. if (mode.isEmitClasses()) {
  3. String fileName = state.type.getInternalName();
  4. if (fileName == null) {
  5. System.err.println("Got null filename from " + state.type);
  6. return null;
  7. }
  8. fileName += ".class";
  9. emitter.emit(fileName, state.contents);
  10. }
  11. if (mode.isEmitSource()) {
  12. String sourcePath = getPackagePath(state.originalType) + state.source;
  13. String destPath = getPackagePath(state.type) + state.source;
  14. if (sources.add(sourcePath) && loader.exists(sourcePath)) {
  15. String contents = Util.readStreamAsString(loader.getResourceAsStream(sourcePath));
  16. emitter.emit(destPath, new ByteArrayInputStream(Util.getBytes(contents)));
  17. }
  18. }
  19. return null;
  20. }
  21. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. public Void call() throws Exception {
  2. if (mode.isEmitClasses()) {
  3. String fileName = state.type.getInternalName();
  4. if (fileName == null) {
  5. System.err.println("Got null filename from " + state.type);
  6. return null;
  7. }
  8. fileName += ".class";
  9. emitter.emit(fileName, state.contents);
  10. }
  11. if (mode.isEmitSource()) {
  12. String sourcePath = getPackagePath(state.originalType) + state.source;
  13. String destPath = getPackagePath(state.type) + state.source;
  14. if (sources.add(sourcePath) && loader.exists(sourcePath)) {
  15. String contents = Util.readStreamAsString(loader.getResourceAsStream(sourcePath));
  16. emitter.emit(destPath, new ByteArrayInputStream(Util.getBytes(contents)));
  17. }
  18. }
  19. return null;
  20. }
  21. }

代码示例来源:origin: com.jhickman/gwt-customuibinder

  1. private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
  2. ResourceOracle resourceOracle, String templatePath)
  3. throws UnableToCompleteException {
  4. Resource resource = resourceOracle.getResourceMap().get(templatePath);
  5. if (null == resource) {
  6. logger.die("Unable to find resource: " + templatePath);
  7. }
  8. Document doc = null;
  9. try {
  10. String content = designTime.getTemplateContent(templatePath);
  11. if (content == null) {
  12. content = Util.readStreamAsString(resource.openContents());
  13. }
  14. doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
  15. content, resource.getPath());
  16. } catch (SAXParseException e) {
  17. logger.die(
  18. "Error parsing XML (line " + e.getLineNumber() + "): "
  19. + e.getMessage(), e);
  20. }
  21. return doc;
  22. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
  2. ResourceOracle resourceOracle, String templatePath, Resource resource)
  3. throws UnableToCompleteException {
  4. Document doc = null;
  5. try {
  6. String content = designTime.getTemplateContent(templatePath);
  7. if (content == null) {
  8. content = Util.readStreamAsString(resource.openContents());
  9. }
  10. doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
  11. content, resource.getPath());
  12. } catch (IOException iex) {
  13. logger.die("Error opening resource:" + resource.getLocation(), iex);
  14. } catch (SAXParseException e) {
  15. logger.die(
  16. "Error parsing XML (line " + e.getLineNumber() + "): "
  17. + e.getMessage(), e);
  18. }
  19. return doc;
  20. }

代码示例来源:origin: net.wetheinter/gwt-user

  1. private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
  2. ResourceOracle resourceOracle, String templatePath, Resource resource)
  3. throws UnableToCompleteException {
  4. Document doc = null;
  5. try {
  6. String content = designTime.getTemplateContent(templatePath);
  7. if (content == null) {
  8. content = Util.readStreamAsString(resource.openContents());
  9. }
  10. doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
  11. content, resource.getPath());
  12. } catch (IOException iex) {
  13. logger.die("Error opening resource:" + resource.getLocation(), iex);
  14. } catch (SAXParseException e) {
  15. logger.die(
  16. "Error parsing XML (line " + e.getLineNumber() + "): "
  17. + e.getMessage(), e);
  18. }
  19. return doc;
  20. }

相关文章