Package java.nio.charset

Examples of java.nio.charset.Charset


      clob.setCharset(cs);
      return new ClobType(clob);
    }
   
    public static Blob toBytes(ClobType value, String encoding) throws IOException {
      Charset cs = getCharset(encoding);
      ClobInputStreamFactory cisf = new ClobInputStreamFactory(value.getReference());
      cisf.setCharset(cs);
      if (CharsetUtils.BASE64_NAME.equalsIgnoreCase(encoding) || CharsetUtils.HEX_NAME.equalsIgnoreCase(encoding)) {
        //validate that the binary conversion is possible
        //TODO: cache the result in a filestore
View Full Code Here


    }
  }

  public void sendModel(final Model model) {
    final RDFFormat dataFormat = pool.getPreferredRDFFormat();
    final Charset charset = dataFormat.hasCharset() ? dataFormat.getCharset() : Charset.forName("UTF-8");
    final RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(dataFormat);
    sendEntity(new RequestEntity() {

      public long getContentLength() {
        return -1; // don't know
      }

      public String getContentType() {
        return dataFormat.getDefaultMIMEType() + "; charset=" + charset.name();
      }

      public boolean isRepeatable() {
        return false;
      }
View Full Code Here

  }

  // convert byte array to char array, assuming UTF-8 encoding

  static protected char[] convertByteToCharUTF(byte[] byteArray) {
    Charset c = Charset.forName("UTF-8");
    CharBuffer output = c.decode(ByteBuffer.wrap(byteArray));
    return output.array();
  }
View Full Code Here

    return output.array();
  }

  // convert char array to byte array, assuming UTF-8 encoding
  static protected byte[] convertCharToByteUTF(char[] from) {
    Charset c = Charset.forName("UTF-8");
    ByteBuffer output = c.encode(CharBuffer.wrap(from));
    return output.array();
  }
View Full Code Here

  public void upload(final Reader contents, String baseURI, final RDFFormat dataFormat, boolean overwrite,
      Resource... contexts)
    throws RDFParseException, StoreException
  {
    final Charset charset = dataFormat.hasCharset() ? dataFormat.getCharset() : Charset.forName("UTF-8");

    RequestEntity entity = new RequestEntity() {

      public long getContentLength() {
        return -1; // don't know
      }

      public String getContentType() {
        return dataFormat.getDefaultMIMEType() + "; charset=" + charset.name();
      }

      public boolean isRepeatable() {
        return false;
      }
View Full Code Here

  }

  static public void testCharsets() {
    Map<String,Charset> map = Charset.availableCharsets();
    for (String key : map.keySet()) {
      Charset cs = map.get(key);
      System.out.println(" "+cs);
    }
    System.out.println("default= "+Charset.defaultCharset());

    System.out.println("\nFont names:");
View Full Code Here

    System.out.println(showBytes(b));
    System.out.println(showBytes(line.getBytes()));
  }

  static void write(String s, String charset) throws IOException {
    Charset cs =  (charset == null) ? Charset.defaultCharset() : Charset.forName(charset);
    OutputStreamWriter outw = new OutputStreamWriter(System.out, cs);
    outw.write("OutputWriter ("+cs+")=(");
    outw.write(s);
    outw.write(")\n");
    outw.flush();
View Full Code Here

    outw.flush();
  }

  static void writeFile(String s, String charset, String filename) throws IOException {
    FileOutputStream fout = new FileOutputStream(filename);
    Charset cs =  (charset == null) ? Charset.defaultCharset() : Charset.forName(charset);
    OutputStreamWriter outw = new OutputStreamWriter(fout, cs);

    outw.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" +
            "    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
            "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
View Full Code Here

        }
        // unreached
    }

    public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
        Charset cs = (this.charset == null)
            ? Charset.forName(encodingName)
            : this.charset;
        CharsetDecoder decoder = cs.newDecoder();

        CodingErrorAction action;
        if (ignoreEncodingErrors)
            action = CodingErrorAction.REPLACE;
        else
View Full Code Here

      // Figure out the default encoding.
      encoding = java.nio.charset.Charset.defaultCharset().name();
  }
  // Try to map the encoding name to a canonical name.
  try {
      Charset cs = Charset.forName(encoding);
      encoding = cs.name();
  } catch (Exception ex) {
      // We hit problems finding a canonical name.
      // Just use the raw encoding name.
 
View Full Code Here

TOP

Related Classes of java.nio.charset.Charset

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.