本文整理汇总了Java中org.w3c.css.sac.InputSource.getByteStream方法的典型用法代码示例。如果您正苦于以下问题:Java InputSource.getByteStream方法的具体用法?Java InputSource.getByteStream怎么用?Java InputSource.getByteStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.css.sac.InputSource
的用法示例。
在下文中一共展示了InputSource.getByteStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReader
import org.w3c.css.sac.InputSource; //导入方法依赖的package包/类
/**
* Convert the source into a Reader. Used only by DOM Level 2 parser methods.
*/
private Reader getReader(InputSource source) throws IOException {
if (source.getCharacterStream() != null) {
return source.getCharacterStream();
} else if (source.getByteStream() != null) {
// My DOM level 2 implementation doesn't use this case.
if (source.getEncoding() == null) {
// unknown encoding, use ASCII as default.
return new InputStreamReader(source.getByteStream(), "ASCII");
} else {
return new InputStreamReader(source.getByteStream(),
source.getEncoding());
}
} else {
// systemId
// @@TODO
throw new CSSException("not yet implemented");
}
}
示例2: createScanner
import org.w3c.css.sac.InputSource; //导入方法依赖的package包/类
/**
* Creates a scanner, given an InputSource.
*/
protected Scanner createScanner(InputSource source) {
documentURI = source.getURI();
if (documentURI == null) {
documentURI = "";
}
Reader r = source.getCharacterStream();
if (r != null) {
return new Scanner(r);
}
InputStream is = source.getByteStream();
if (is != null) {
return new Scanner(is, source.getEncoding());
}
String uri = source.getURI();
if (uri == null) {
throw new CSSException(formatMessage("empty.source", null));
}
try {
ParsedURL purl = new ParsedURL(uri);
is = purl.openStreamRaw(CSSConstants.CSS_MIME_TYPE);
return new Scanner(is, source.getEncoding());
} catch (IOException e) {
throw new CSSException(e);
}
}