public static CSSInputStream stringStream(String source) throws IOException { CSSInputStream stream = new CSSInputStream(); stream.rawData = source; stream.encoding = Charset.defaultCharset().name(); BufferedReader br = new BufferedReader( new InputStreamReader(new ByteArrayInputStream(source.getBytes()), stream.encoding)); stream.input = new ANTLRReaderStream(br); return stream; }
public static CSSInputStream stringStream(String source) throws IOException { CSSInputStream stream = new CSSInputStream(); stream.rawData = source; stream.encoding = Charset.defaultCharset().name(); BufferedReader br = new BufferedReader( new InputStreamReader(new ByteArrayInputStream(source.getBytes()), stream.encoding)); stream.input = new ANTLRReaderStream(br); return stream; }
public static CSSInputStream urlStream(URL source, String encoding) throws IOException { CSSInputStream stream = new CSSInputStream(); stream.base = source; if (encoding != null) stream.encoding = encoding; else stream.encoding = Charset.defaultCharset().name(); URLConnection con = source.openConnection(); InputStream is; if ("gzip".equalsIgnoreCase(con.getContentEncoding())) is = new GZIPInputStream(con.getInputStream()); else is = con.getInputStream(); stream.input = new ANTLRInputStream(is, stream.encoding); stream.source = is; stream.url = source; return stream; }
public static CSSInputStream urlStream(URL source, NetworkProcessor network, String encoding) throws IOException { CSSInputStream stream = new CSSInputStream(); stream.base = source; if (encoding != null) stream.encoding = encoding; else stream.encoding = Charset.defaultCharset().name(); InputStream is = network.fetch(source); stream.input = new ANTLRInputStream(is, stream.encoding); stream.source = is; stream.url = source; return stream; }