use of java.io.CharArrayReader in project vcell by virtualcell.
the class SolverDescriptionRegression method readback.
// @Test
public void readback() throws IOException {
CharArrayWriter buffer = new CharArrayWriter();
PrintWriter record = new PrintWriter(buffer);
for (String name : SolverNames) {
dumpOne(name, record);
}
record.flush();
char[] b = buffer.toCharArray();
BufferedReader current = new BufferedReader(new CharArrayReader(b));
LineNumberReader reference = new LineNumberReader(new FileReader("solvers.ref"));
boolean nameNext = false;
String currentSolver = null;
while (reference.ready()) {
String currentLine = current.readLine();
String referenceLine = reference.readLine();
if (nameNext) {
currentSolver = currentLine;
nameNext = false;
} else if (currentLine.equals(SOLVER_SEP)) {
nameNext = true;
}
if (!currentLine.equals(referenceLine)) {
System.err.println("mismatch in " + currentSolver + " line " + reference.getLineNumber());
System.err.println("\treference " + referenceLine);
System.err.println("\tcurrent " + currentLine);
}
}
reference.close();
}
use of java.io.CharArrayReader in project Payara by payara.
the class JPAStandardSchemaGenerationProcessor method getOverridesForSuppressingSchemaGeneration.
@Override
public Map<String, Object> getOverridesForSuppressingSchemaGeneration() {
Map<String, Object> overrides = new HashMap<>();
// suppress database action
overrides.put(SCHEMA_GENERATION_DATABASE_ACTION_PROPERTY, SCHEMA_GENERATION_ACTION_NONE);
// suppress script action
overrides.put(SCHEMA_GENERATION_SCRIPTS_ACTION_PROPERTY, SCHEMA_GENERATION_ACTION_NONE);
// suppress execution of load scripts
overrides.put(SQL_LOAD_SCRIPT_SOURCE, new CharArrayReader(new char[0]));
return overrides;
}
use of java.io.CharArrayReader in project ceylon-compiler by ceylon.
the class JavaPositionsRetriever method addCeylonLinesComments.
private String addCeylonLinesComments(char[] source) {
String annotatedSourceCode = "";
BufferedReader reader = new BufferedReader(new CharArrayReader(source));
String line = null;
int javaLine = 1;
try {
while ((line = reader.readLine()) != null) {
annotatedSourceCode += line;
String ceylonLines = getCeylonLinesForJavaLine(revertMap(ceylonToJavaLines), javaLine);
annotatedSourceCode += ceylonLines.isEmpty() ? "" : " // line " + ceylonLines;
annotatedSourceCode += "\n";
javaLine++;
}
} catch (IOException e) {
e.printStackTrace();
}
return annotatedSourceCode;
}
use of java.io.CharArrayReader in project hive by apache.
the class OpenCSVSerde method deserialize.
@Override
public Object deserialize(final Writable blob) throws SerDeException {
Text rowText = (Text) blob;
CSVReader csv = null;
try {
csv = newReader(new CharArrayReader(rowText.toString().toCharArray()), separatorChar, quoteChar, escapeChar);
final String[] read = csv.readNext();
for (int i = 0; i < numCols; i++) {
if (read != null && i < read.length) {
row.set(i, read[i]);
} else {
row.set(i, null);
}
}
return row;
} catch (final Exception e) {
throw new SerDeException(e);
} finally {
if (csv != null) {
try {
csv.close();
} catch (final Exception e) {
LOG.error("fail to close csv writer ", e);
}
}
}
}
use of java.io.CharArrayReader in project j2objc by google.
the class OldCharArrayReaderTest method test_Constructor$CII.
/**
* java.io.CharArrayReader#CharArrayReader(char[], int, int)
*/
public void test_Constructor$CII() throws IOException {
try {
cr = new CharArrayReader(null, 0, 0);
fail("Test 1: NullPointerException expected.");
} catch (NullPointerException e) {
// Expected.
}
try {
cr = new CharArrayReader(hw, -1, 0);
fail("Test 2: IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// Expected.
}
try {
cr = new CharArrayReader(hw, 0, -1);
fail("Test 3: IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// Expected.
}
try {
cr = new CharArrayReader(hw, hw.length + 1, 1);
fail("Test 4: IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// Expected.
}
cr = new CharArrayReader(hw, 5, 5);
assertTrue("Test 5: Failed to create reader", cr.ready());
assertEquals("Test 6: Incorrect character read;", 'W', cr.read());
}
Aggregations