Search in sources :

Example 31 with CharArrayReader

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();
}
Also used : CharArrayReader(java.io.CharArrayReader) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) CharArrayWriter(java.io.CharArrayWriter) PrintWriter(java.io.PrintWriter) LineNumberReader(java.io.LineNumberReader)

Example 32 with CharArrayReader

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;
}
Also used : CharArrayReader(java.io.CharArrayReader) HashMap(java.util.HashMap)

Example 33 with CharArrayReader

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;
}
Also used : CharArrayReader(java.io.CharArrayReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Example 34 with CharArrayReader

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);
            }
        }
    }
}
Also used : CharArrayReader(java.io.CharArrayReader) CSVReader(au.com.bytecode.opencsv.CSVReader) Text(org.apache.hadoop.io.Text) IOException(java.io.IOException)

Example 35 with CharArrayReader

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());
}
Also used : CharArrayReader(java.io.CharArrayReader)

Aggregations

CharArrayReader (java.io.CharArrayReader)64 IOException (java.io.IOException)37 BufferedReader (java.io.BufferedReader)16 Reader (java.io.Reader)13 InputStreamReader (java.io.InputStreamReader)8 File (java.io.File)6 FileReader (java.io.FileReader)6 StringReader (java.io.StringReader)6 BufferedWriter (java.io.BufferedWriter)5 CharArrayWriter (java.io.CharArrayWriter)5 FileWriter (java.io.FileWriter)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 PipedReader (java.io.PipedReader)4 Signature (java.security.Signature)4 DataFormatException (java.util.zip.DataFormatException)4 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)4 PEMParser (org.bouncycastle.openssl.PEMParser)4 JcaPEMKeyConverter (org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter)4 Document (org.w3c.dom.Document)4 InputStream (java.io.InputStream)3