Package java.io

Examples of java.io.CharArrayReader


        cbuf[randomOffset] = 'e';
        for (int i = 0; i < 10; i++) {
            ps.setInt(1, i);
            ps.setString(2, "mname" + i);
            ps.setInt(3, 0);
            ps.setCharacterStream(4, new CharArrayReader(cbuf), len);
            ps.setAsciiStream(5, new ByteArrayInputStream(buf), len);
            rowCount += ps.executeUpdate();
        }
        commit();
        println("Rows inserted =" + rowCount);

        try {
            ps.setInt(1, 11);
            rowCount += ps.executeUpdate();
        } catch (SQLException sqle) {
            if (usingDerbyNetClient()) {
              // DERBY-4315.  This SQLState is wrong for client.
              // It should have the same behavior as embedded.
              // That may rquire some additional work in addition
              // to DERBY-4315.
              // Remove special case when DERBY-4315
              // is fixed or at least throw XJ001 and
              // avoid bad data insert.
                assertSQLState("XN017", sqle);
                // rollback the bad insert.
                rollback();
            } else {
                println("UNEXPECTED EXCEPTION - streams cannot be "
                        + "re-used but in case of varchar, stream is materialized the"
                        + " first time around. So multiple executions using streams should "
                        + " work fine. ");
                throw sqle;
            }
        }

        PreparedStatement pss = prepareStatement(" select lvc,vc from test500_verify where "
                + "id = ?");
        verifyDerby500Test(pss, buf, cbuf, 0, 10, false);

        // do the update, update must qualify more than 1 row and update will
        // pass for char,varchar,long varchar columns.
        PreparedStatement psu = prepareStatement("update test500_verify set vc = ? "
                + ", lvc = ? where mvalue = ?  ");

        buf[randomOffset + 1] = (byte) 'u';
        cbuf[randomOffset + 1] = 'u';
        rowCount = 0;
        psu.setAsciiStream(1, new ByteArrayInputStream(buf), len);
        psu.setCharacterStream(2, new CharArrayReader(cbuf), len);
        psu.setInt(3, 0);
        rowCount += psu.executeUpdate();

        println("DERBY500 for varchar #1 Rows updated  =" + rowCount);
View Full Code Here


            runTests(in, out);
            out.close();
            in.close();

            LineNumberReader expected = new LineNumberReader(new InputStreamReader(getClass().getResourceAsStream("parserTestsOutput.txt"), UTF8));
            LineNumberReader actual = new LineNumberReader(new CharArrayReader(writer.toCharArray()));

            Assert.assertFalse(isDifferentStreams(actual, expected));
            actual.close();
            expected.close();
        } finally {
View Full Code Here

                break;
            }
          }
        }
      }
      return new CharArrayReader(writer.toCharArray());
    }
    catch(Exception e )
    {
      //logger.warn("WARNING: Problem converting excel document"+e);
      EOD = true;
View Full Code Here

      stripper.setLineSeparator("\n");
      stripper.writeText(document, writer);
      document.close();
      writer.close();
      parser.getDocument().close();
      return new CharArrayReader(writer.toCharArray());
    }catch (Exception e){
        //logger.warn("WARNING: Problem converting PDF: ",e);
      try{
        document.close();       
      }catch(Exception e1){
View Full Code Here

                throws SQLException {
        // Process common types first.
        if (parameter instanceof String) {
            // Check for stream binding of large strings.
            if (usesStringBinding() && (((String)parameter).length() > getStringBindingSize())) {
                CharArrayReader reader = new CharArrayReader(((String)parameter).toCharArray());
                statement.setCharacterStream(index, reader, ((String)parameter).length());
            }
            statement.setString(index, (String) parameter);
        } else if (parameter instanceof Number) {
            Number number = (Number) parameter;
View Full Code Here

      expected[i] = (char) (this.random.nextInt(max - min) + min);
    }

    InputSinkChannel<Reader, S> channel = this.strategy.createReaderChannel();
   
    S sink = channel.write(new CharArrayReader(expected));
   
    Reader reader = channel.read(sink);
    try
    {
      char[] result = new char[Short.MAX_VALUE];
View Full Code Here

     * @param s the string to convert
     * @param uncompress use gzip to uncompress the stream of bytes
     */
    public static byte[] decode( String s, boolean uncompress ) throws IOException {
        char[] chars = s.toCharArray();
        CharArrayReader car = new CharArrayReader(chars);
        JavaReader jr = new JavaReader(car);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        int ch;
        while ((ch = jr.read()) >= 0) {
            bos.write(ch);
        }
        bos.close();
        car.close();
        jr.close();
        byte[] bytes = bos.toByteArray();
        if (uncompress) {
            GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes));
            byte[] tmp = new byte[bytes.length * 3]; // Rough estimate
View Full Code Here

  private HqlBaseLexer lexer;
  private Token token;

  public AntlrSimpleHQLLexer(char[] cs, int length) {
    lexer = new HqlBaseLexer(new CharArrayReader(cs, 0, length)) {
      public void newline() {
        //super.newline();
      }
     
      public int getColumn() {
View Full Code Here

  public abstract Class getReturnedClass();

  public void set(PreparedStatement st, Object value, int index) throws SQLException {
    char[] chars = toInternalFormat( value );
    st.setCharacterStream(index, new CharArrayReader(chars), chars.length);
  }
View Full Code Here

        if (reader != null) {
            result = reader;
            inputStream = null;
        }
        else if (content != null) {
            result = new CharArrayReader(content);
            inputStream = null;
            reader = null;
        }
        else if (inputStream != null) {
            result = new InputStreamReader(inputStream);
            reader = null;
        }
        else if (contentBytes != null) {
            result = new CharArrayReader(new String(contentBytes).toCharArray());
            inputStream = null;
            reader = null;
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of java.io.CharArrayReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.