![JAR search and dependency download from the Maven repository](/logo.png)
com.laamella.sexpression.CharSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of s-expressions Show documentation
Show all versions of s-expressions Show documentation
S-Expression support for Java
package com.laamella.sexpression;
import java.io.*;
import java.nio.charset.Charset;
public class CharSource {
public static Charset UTF8 = Charset.forName("utf-8");
public static void push(Reader reader, T charSink) throws IOException {
while (true) {
int c = reader.read();
if (c == -1) {
charSink.close();
return;
}
charSink.accept((char) c);
}
}
public static void pushResource(String resourceName, Charset encoding, T charSink) throws IOException {
try (
InputStream resourceAsStream = CharSource.class.getResourceAsStream(resourceName);
InputStreamReader reader = new InputStreamReader(resourceAsStream, encoding);
) {
push(reader, charSink);
}
}
public static void pushString(String string, T charSink) throws IOException {
push(new StringReader(string), charSink);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy