Package java.nio.charset

Examples of java.nio.charset.Charset.decode()


        while (i < len && data[i] != '\'') i++;
        i++;
      } while (i < len && data[i] != ','); // word must end with "',"
     
      if (i >= len) break; // EOF
      String word = charset.decode(ByteBuffer.wrap(data, start, i-start-1)).toString();
//      String word = new String(data, 0, start, i-start-1); // ASCII
     
      /*
       * Part B: ignore phrases (with spaces and hyphens) and
       * non-alphabetic words, and let user customize word (e.g. do some
View Full Code Here


                        buf = ByteBuffer.allocate(128);
                        Charset charset = Charset.forName(System.getProperty("file.encoding"));
                        StringBuilder builder = new StringBuilder();
                        while (socketChannel.read(buf) != -1) {
                            buf.flip();
                            builder.append(charset.decode(buf));
                            buf.clear();
                        }
                        System.out.println("Server response: " + builder.toString());
                    } catch (IOException e) {
                        e.printStackTrace();
View Full Code Here

        StringBuilder builder = new StringBuilder();
        try {
            sock.configureBlocking(false);
            while(sock.read(buffer) > 0) {
                buffer.flip();
                builder.append(charset.decode(buffer));
                buffer.clear();
            }
            System.out.printf("From client #%d:\n%s\n", numOfCon, builder.toString());
            String respBody = "<html>" +
                    "<body>Hello, world</body>" +
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.