Java Code Examples for com.google.common.io.ByteSource#asCharSource()
The following examples show how to use
com.google.common.io.ByteSource#asCharSource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCodeProvider.java From n4js with Eclipse Public License 1.0 | 6 votes |
/***/ public static String getContentsFromFileEntry(final ZipEntry entry, String rootName) throws IOException, URISyntaxException { URL rootURL = Thread.currentThread().getContextClassLoader().getResource(rootName); try (final ZipFile root = new ZipFile(new File(rootURL.toURI()));) { ByteSource byteSource = new ByteSource() { @Override public InputStream openStream() throws IOException { return root.getInputStream(entry); } }; CharSource charSrc = byteSource.asCharSource(Charsets.UTF_8); return charSrc.read(); } }
Example 2
Source File: JSLibSingleTestConfigProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * @param resourceName * the classpath-relative location of the to-be-read resource */ private static List<String> getFileLines(final String resourceName) throws IOException { ByteSource byteSource = new ByteSource() { @Override public InputStream openStream() throws IOException { return Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName); } }; CharSource charSrc = byteSource.asCharSource(Charsets.UTF_8); return charSrc.readLines(); }
Example 3
Source File: IOHelper.java From purplejs with Apache License 2.0 | 4 votes |
public static CharSource toCharSource( final ByteSource source ) { return source.asCharSource( Charsets.UTF_8 ); }