當前位置: 首頁>>代碼示例>>Java>>正文


Java Charset.equals方法代碼示例

本文整理匯總了Java中java.nio.charset.Charset.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Charset.equals方法的具體用法?Java Charset.equals怎麽用?Java Charset.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.charset.Charset的用法示例。


在下文中一共展示了Charset.equals方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: StrictLineReader

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
 * Constructs a new {@code LineReader} with the specified capacity and charset.
 *
 * @param in the {@code InputStream} to read data from.
 * @param capacity the capacity of the buffer.
 * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
 * supported.
 * @throws NullPointerException if {@code in} or {@code charset} is null.
 * @throws IllegalArgumentException if {@code capacity} is negative or zero
 * or the specified charset is not supported.
 */
public StrictLineReader(InputStream in, int capacity, Charset charset) {
  if (in == null || charset == null) {
    throw new NullPointerException();
  }
  if (capacity < 0) {
    throw new IllegalArgumentException("capacity <= 0");
  }
  if (!(charset.equals(Util.US_ASCII))) {
    throw new IllegalArgumentException("Unsupported encoding");
  }

  this.in = in;
  this.charset = charset;
  buf = new byte[capacity];
}
 
開發者ID:senierr,項目名稱:ModuleFrame,代碼行數:27,代碼來源:StrictLineReader.java

示例2: StrictLineReader

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
 * Constructs a new {@code LineReader} with the specified capacity and charset.
 *
 * @param in the {@code InputStream} to read data from.
 * @param capacity the capacity of the buffer.
 * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
 * supported.
 * @throws NullPointerException if {@code in} or {@code charset} is null.
 * @throws IllegalArgumentException if {@code capacity} is negative or zero
 * or the specified charset is not supported.
 */
public StrictLineReader(InputStream in, int capacity, Charset charset) {
  if (in == null || charset == null) {
    throw new NullPointerException();
  }
  if (capacity < 0) {
    throw new IllegalArgumentException("capacity <= 0");
  }
  if (!(charset.equals(IOUtil.US_ASCII))) {
    throw new IllegalArgumentException("Unsupported encoding");
  }

  this.in = in;
  this.charset = charset;
  buf = new byte[capacity];
}
 
開發者ID:SingleShu,項目名稱:ImageLoaderLibrary,代碼行數:27,代碼來源:StrictLineReader.java

示例3: B2CConverter

import java.nio.charset.Charset; //導入方法依賴的package包/類
public B2CConverter(String encoding, boolean replaceOnError)
        throws IOException {
    byte[] left = new byte[LEFTOVER_SIZE];
    leftovers = ByteBuffer.wrap(left);
    CodingErrorAction action;
    if (replaceOnError) {
        action = CodingErrorAction.REPLACE;
    } else {
        action = CodingErrorAction.REPORT;
    }
    Charset charset = getCharset(encoding);
    // Special case. Use the Apache Harmony based UTF-8 decoder because it
    // - a) rejects invalid sequences that the JVM decoder does not
    // - b) fails faster for some invalid sequences
    if (charset.equals(UTF_8)) {
        decoder = new Utf8Decoder();
    } else {
        decoder = charset.newDecoder();
    }
    decoder.onMalformedInput(action);
    decoder.onUnmappableCharacter(action);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:23,代碼來源:B2CConverter.java

示例4: StrictLineReader

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
 * Constructs a new {@code LineReader} with the specified capacity and charset.
 *
 * @param in       the {@code InputStream} to read data from.
 * @param capacity the capacity of the buffer.
 * @param charset  the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
 *                 supported.
 * @throws NullPointerException     if {@code in} or {@code charset} is null.
 * @throws IllegalArgumentException if {@code capacity} is negative or zero
 *                                  or the specified charset is not supported.
 */
public StrictLineReader(InputStream in, int capacity, Charset charset) {
    if (in == null || charset == null) {
        throw new NullPointerException();
    }
    if (capacity < 0) {
        throw new IllegalArgumentException("capacity <= 0");
    }
    if (!(charset.equals(Util.US_ASCII))) {
        throw new IllegalArgumentException("Unsupported encoding");
    }

    this.in = in;
    this.charset = charset;
    buf = new byte[capacity];
}
 
開發者ID:xiaoyaoyou1212,項目名稱:XSnow,代碼行數:27,代碼來源:DiskLruCache.java

示例5: B2CConverter

import java.nio.charset.Charset; //導入方法依賴的package包/類
public B2CConverter(String encoding, boolean replaceOnError) throws IOException {
	byte[] left = new byte[LEFTOVER_SIZE];
	leftovers = ByteBuffer.wrap(left);
	CodingErrorAction action;
	if (replaceOnError) {
		action = CodingErrorAction.REPLACE;
	} else {
		action = CodingErrorAction.REPORT;
	}
	Charset charset = getCharset(encoding);
	// Special case. Use the Apache Harmony based UTF-8 decoder because it
	// - a) rejects invalid sequences that the JVM decoder does not
	// - b) fails faster for some invalid sequences
	if (charset.equals(UTF_8)) {
		decoder = new Utf8Decoder();
	} else {
		decoder = charset.newDecoder();
	}
	decoder.onMalformedInput(action);
	decoder.onUnmappableCharacter(action);
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:22,代碼來源:B2CConverter.java

示例6: StrictLineReader

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
 * Constructs a new {@code LineReader} with the specified capacity and charset.
 *
 * @param in the {@code InputStream} to read data from.
 * @param capacity the capacity of the buffer.
 * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
 * supported.
 * @throws NullPointerException if {@code in} or {@code charset} is null.
 * @throws IllegalArgumentException if {@code capacity} is negative or zero
 * or the specified charset is not supported.
 */
public StrictLineReader(InputStream in, int capacity, Charset charset) {
    if (in == null || charset == null) {
        throw new NullPointerException();
    }
    if (capacity < 0) {
        throw new IllegalArgumentException("capacity <= 0");
    }
    if (!(charset.equals(Util.US_ASCII))) {
        throw new IllegalArgumentException("Unsupported encoding");
    }

    this.in = in;
    this.charset = charset;
    buf = new byte[capacity];
}
 
開發者ID:yale8848,項目名稱:CacheWebView,代碼行數:27,代碼來源:StrictLineReader.java

示例7: StrictLineReader

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
 * Constructs a new {@code LineReader} with the specified capacity and charset.
 *
 * @param in the {@code InputStream} to read data from.
 * @param capacity the capacity of the buffer.
 * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
 *     supported.
 * @throws NullPointerException if {@code in} or {@code charset} is null.
 * @throws IllegalArgumentException if {@code capacity} is negative or zero
 *     or the specified charset is not supported.
 */
public StrictLineReader(InputStream in, int capacity, Charset charset) {
  if (in == null || charset == null) {
    throw new NullPointerException();
  }
  if (capacity < 0) {
    throw new IllegalArgumentException("capacity <= 0");
  }
  if (!(charset.equals(Util.US_ASCII))) {
    throw new IllegalArgumentException("Unsupported encoding");
  }

  this.in = in;
  this.charset = charset;
  buf = new byte[capacity];
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:27,代碼來源:StrictLineReader.java

示例8: StrictLineReader

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
 * Constructs a new {@code LineReader} with the specified capacity and charset.
 *
 * @param in       the {@code InputStream} to read data from.
 * @param capacity the capacity of the buffer.
 * @param charset  the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
 *                 supported.
 * @throws NullPointerException     if {@code in} or {@code charset} is null.
 * @throws IllegalArgumentException if {@code capacity} is negative or zero
 *                                  or the specified charset is not supported.
 */
public StrictLineReader(InputStream in, int capacity, Charset charset) {
  if (in == null || charset == null) {
    throw new NullPointerException();
  }
  if (capacity < 0) {
    throw new IllegalArgumentException("capacity <= 0");
  }
  if (!(charset.equals(Util.US_ASCII))) {
    throw new IllegalArgumentException("Unsupported encoding");
  }

  this.in = in;
  this.charset = charset;
  buf = new byte[capacity];
}
 
開發者ID:qiaodashaoye,項目名稱:SuperHttp,代碼行數:27,代碼來源:DiskLruCache.java

示例9: StrictLineReader

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
 * Constructs a new {@code LineReader} with the specified capacity and charset.
 *
 * @param in the {@code InputStream} to read data from.
 * @param capacity the capacity of the buffer.
 * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
 * supported.
 * @throws NullPointerException if {@code in} or {@code charset} is null.
 * @throws IllegalArgumentException if {@code capacity} is negative or zero
 * or the specified charset is not supported.
 */
public StrictLineReader(InputStream in, int capacity, Charset charset) {
	if (in == null || charset == null) {
		throw new NullPointerException();
	}
	if (capacity < 0) {
		throw new IllegalArgumentException("capacity <= 0");
	}
	if (!(charset.equals(Util.US_ASCII))) {
		throw new IllegalArgumentException("Unsupported encoding");
	}

	this.in = in;
	this.charset = charset;
	buf = new byte[capacity];
}
 
開發者ID:Spencer231,項目名稱:GifImageLoader,代碼行數:27,代碼來源:StrictLineReader.java

示例10: writeString

import java.nio.charset.Charset; //導入方法依賴的package包/類
public Buffer writeString(String string, int beginIndex, int endIndex, Charset charset) {
    if (string == null) {
        throw new IllegalArgumentException("string == null");
    } else if (beginIndex < 0) {
        throw new IllegalAccessError("beginIndex < 0: " + beginIndex);
    } else if (endIndex < beginIndex) {
        throw new IllegalArgumentException("endIndex < beginIndex: " + endIndex + " < " + beginIndex);
    } else if (endIndex > string.length()) {
        throw new IllegalArgumentException("endIndex > string.length: " + endIndex + " > " + string.length());
    } else if (charset == null) {
        throw new IllegalArgumentException("charset == null");
    } else if (charset.equals(Util.UTF_8)) {
        return writeUtf8(string);
    } else {
        byte[] data = string.substring(beginIndex, endIndex).getBytes(charset);
        return write(data, 0, data.length);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:19,代碼來源:Buffer.java

示例11: asCharSource

import java.nio.charset.Charset; //導入方法依賴的package包/類
@Override
public CharSource asCharSource(Charset charset) {
  if (charset.equals(this.charset)) {
    return CharSource.this;
  }
  return super.asCharSource(charset);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:8,代碼來源:CharSource.java

示例12: asByteSource

import java.nio.charset.Charset; //導入方法依賴的package包/類
@Override
public ByteSource asByteSource(Charset charset) {
  if (charset.equals(this.charset)) {
    return ByteSource.this;
  }
  return super.asByteSource(charset);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:8,代碼來源:ByteSource.java

示例13: StrictLineReader

import java.nio.charset.Charset; //導入方法依賴的package包/類
public StrictLineReader(InputStream in, int capacity, Charset charset) {
    if (in == null || charset == null) {
        throw new NullPointerException();
    } else if (capacity < 0) {
        throw new IllegalArgumentException("capacity <= 0");
    } else if (charset.equals(Util.US_ASCII)) {
        this.in = in;
        this.charset = charset;
        this.buf = new byte[capacity];
    } else {
        throw new IllegalArgumentException("Unsupported encoding");
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:14,代碼來源:StrictLineReader.java

示例14: canonicalize

import java.nio.charset.Charset; //導入方法依賴的package包/類
static void canonicalize(Buffer out, String input, int pos, int limit, String encodeSet,
    boolean alreadyEncoded, boolean strict, boolean plusIsSpace, boolean asciiOnly,
    Charset charset) {
  Buffer encodedCharBuffer = null; // Lazily allocated.
  int codePoint;
  for (int i = pos; i < limit; i += Character.charCount(codePoint)) {
    codePoint = input.codePointAt(i);
    if (alreadyEncoded
        && (codePoint == '\t' || codePoint == '\n' || codePoint == '\f' || codePoint == '\r')) {
      // Skip this character.
    } else if (codePoint == '+' && plusIsSpace) {
      // Encode '+' as '%2B' since we permit ' ' to be encoded as either '+' or '%20'.
      out.writeUtf8(alreadyEncoded ? "+" : "%2B");
    } else if (codePoint < 0x20
        || codePoint == 0x7f
        || codePoint >= 0x80 && asciiOnly
        || encodeSet.indexOf(codePoint) != -1
        || codePoint == '%' && (!alreadyEncoded || strict && !percentEncoded(input, i, limit))) {
      // Percent encode this character.
      if (encodedCharBuffer == null) {
        encodedCharBuffer = new Buffer();
      }

      if (charset == null || charset.equals(Util.UTF_8)) {
        encodedCharBuffer.writeUtf8CodePoint(codePoint);
      } else {
        encodedCharBuffer.writeString(input, i, i + Character.charCount(codePoint), charset);
      }

      while (!encodedCharBuffer.exhausted()) {
        int b = encodedCharBuffer.readByte() & 0xff;
        out.writeByte('%');
        out.writeByte(HEX_DIGITS[(b >> 4) & 0xf]);
        out.writeByte(HEX_DIGITS[b & 0xf]);
      }
    } else {
      // This character doesn't need encoding. Just copy it over.
      out.writeUtf8CodePoint(codePoint);
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:42,代碼來源:HttpUrl.java

示例15: isAllowedEncoding

import java.nio.charset.Charset; //導入方法依賴的package包/類
protected boolean isAllowedEncoding(Charset enc)
{
    return enc.equals(VorbisHeader.CHARSET_UTF_8);
}
 
開發者ID:GlennioTech,項目名稱:MetadataEditor,代碼行數:5,代碼來源:VorbisCommentTag.java


注:本文中的java.nio.charset.Charset.equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。