Package java.nio

Examples of java.nio.CharBuffer.flip()


  }
  public static byte[] getBytes (char[] chars) {
    Charset cs = Charset.forName ("UTF-8");
    CharBuffer cb = CharBuffer.allocate (chars.length);
    cb.put (chars);
                cb.flip ();
    ByteBuffer bb = cs.encode (cb);
   
    return bb.array();
        }
View Full Code Here


  }
  public static byte[] getBytes (char[] chars) {
    Charset cs = Charset.forName ("UTF-8");
    CharBuffer cb = CharBuffer.allocate (chars.length);
    cb.put (chars);
                cb.flip ();
    ByteBuffer bb = cs.encode (cb);
   
    return bb.array();
        }
View Full Code Here

  }
  public static byte[] getBytes (char[] chars) {
    Charset cs = Charset.forName ("UTF-8");
    CharBuffer cb = CharBuffer.allocate (chars.length);
    cb.put (chars);
                cb.flip ();
    ByteBuffer bb = cs.encode (cb);
   
    return bb.array();
        }
View Full Code Here

  @Private static void copy(Readable from, Appendable to) throws IOException {
     CharBuffer buf = CharBuffer.allocate(2048);
     for (;;) {
       int r = from.read(buf);
       if (r == -1) break;
       buf.flip();
       to.append(buf, 0, r);
     }
  }
 
  @SuppressWarnings("unchecked")
View Full Code Here

            FileReader reader = new FileReader(config._temp);
            CharBuffer buffer = CharBuffer.allocate(256 * 1024);
            reader.read(buffer);
            reader.close();
            config._temp.delete();
            buffer.flip();

            String raw = buffer.toString();
            System.out.print(raw);
            Stats stats = new Stats(raw, repeat);
            System.out.println(stats);
View Full Code Here

            for (int i = 0; i < length; i++) {
                final char next = searchContent.charAt(i);
                final char upperCase = Character.toUpperCase(next);
                buffer.put(upperCase);
            }
            buffer.flip();
        } else {
            buffer = CharBuffer.wrap(searchContent);
        }
        return buffer;
    }
View Full Code Here

               
        CharBuffer cb = CharBuffer.allocate(numChars);
        rdin.read(cb);
       
        fin.close();
        return cb.flip().toString();
    }

    public void testBasicDecoding() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
View Full Code Here

               
        CharBuffer cb = CharBuffer.allocate(numChars);
        rdin.read(cb);
       
        fin.close();
        return cb.flip().toString();
    }

    public void testBasicDecoding() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
View Full Code Here

      // although the approach (to replace last char) is depressingly awful
      CharSequence cs = pathHelper.rewrite(p);
      CharBuffer cb = CharBuffer.allocate(cs.length());
      cb.append(cs);
      cb.put(cs.length()-1, 'd');
      cb.flip();
      added.add(cb);
    }
    FileOutputStream fos = null;
    f = tr.prepare(f);
    try {
View Full Code Here

                appendString(charBuffer, contentType);
            }
            charBuffer.put(SPACE);
        }
        charBuffer.put("\n");
        charBuffer.flip();
        logString = charBuffer.toString();
        if (logString != null && !logString.trim().equals(""))
            log(header + logString);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.