⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 string.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
   * @see #split(String, int)   * @see Pattern#compile(String)   * @see Pattern#split(CharSequence, int)   * @since 1.4   */  public String[] split(String regex)  {    return Pattern.compile(regex).split(this, 0);  }  /**   * Lowercases this String according to a particular locale. This uses   * Unicode's special case mappings, as applied to the given Locale, so the   * resulting string may be a different length.   *   * @param loc locale to use   * @return new lowercased String, or this if no characters were lowercased   * @throws NullPointerException if loc is null   * @see #toUpperCase(Locale)   * @since 1.1   */  public native String toLowerCase(Locale locale);  /**   * Lowercases this String. This uses Unicode's special case mappings, as   * applied to the platform's default Locale, so the resulting string may   * be a different length.   *   * @return new lowercased String, or this if no characters were lowercased   * @see #toLowerCase(Locale)   * @see #toUpperCase()   */  public String toLowerCase()  {    // The JDK is a bit confused about what to do here.  If we pass in    // the default Locale then special Locale handling might be    // invoked.  However, the docs also say that Character.toLowerCase    // rules here.  We go with the latter.    return toLowerCase (null);  }  /**   * Uppercases this String according to a particular locale. This uses   * Unicode's special case mappings, as applied to the given Locale, so the   * resulting string may be a different length.   *   * @param loc locale to use   * @return new uppercased String, or this if no characters were uppercased   * @throws NullPointerException if loc is null   * @see #toLowerCase(Locale)   * @since 1.1   */  public native String toUpperCase(Locale locale);  /**   * Uppercases this String. This uses Unicode's special case mappings, as   * applied to the platform's default Locale, so the resulting string may   * be a different length.   *   * @return new uppercased String, or this if no characters were uppercased   * @see #toUpperCase(Locale)   * @see #toLowerCase()   */  public String toUpperCase()  {    // The JDK is a bit confused about what to do here.  If we pass in    // the default Locale then special Locale handling might be    // invoked.  However, the docs also say that Character.toLowerCase    // rules here.  We go with the latter.    return toUpperCase (null);  }  /**   * Trims all characters less than or equal to <code>'\u0020'</code>   * (<code>' '</code>) from the beginning and end of this String. This   * includes many, but not all, ASCII control characters, and all   * {@link Character#whitespace(char)}.   *   * @return new trimmed String, or this if nothing trimmed   */  public native String trim();  /**   * Returns this, as it is already a String!   *   * @return this   */  public String toString()  {    return this;  }  /**   * Copies the contents of this String into a character array. Subsequent   * changes to the array do not affect the String.   *   * @return character array copying the String   */  public native char[] toCharArray();  /**   * Returns a String representation of an Object. This is "null" if the   * object is null, otherwise it is <code>obj.toString()</code> (which   * can be null).   *   * @param obj the Object   * @return the string conversion of obj   */  public static String valueOf(Object obj)  {    return obj == null ? "null" : obj.toString();  }  /**   * Returns a String representation of a character array. Subsequent   * changes to the array do not affect the String.   *   * @param data the character array   * @return a String containing the same character sequence as data   * @throws NullPointerException if data is null   * @see #valueOf(char[], int, int)   * @see #String(char[])   */  public static String valueOf(char[] data)  {    return valueOf (data, 0, data.length);  }  /**   * Returns a String representing the character sequence of the char array,   * starting at the specified offset, and copying chars up to the specified   * count. Subsequent changes to the array do not affect the String.   *   * @param data character array   * @param offset position (base 0) to start copying out of data   * @param count the number of characters from data to copy   * @return String containing the chars from data[offset..offset+count]   * @throws NullPointerException if data is null   * @throws IndexOutOfBoundsException if (offset &lt; 0 || count &lt; 0   *         || offset + count &gt; data.length)   *         (while unspecified, this is a StringIndexOutOfBoundsException)   * @see #String(char[], int, int)   */  public static native String valueOf(char[] data, int offset, int count);  /**   * Returns a String representing the character sequence of the char array,   * starting at the specified offset, and copying chars up to the specified   * count. Subsequent changes to the array do not affect the String.   *   * @param data character array   * @param offset position (base 0) to start copying out of data   * @param count the number of characters from data to copy   * @return String containing the chars from data[offset..offset+count]   * @throws NullPointerException if data is null   * @throws IndexOutOfBoundsException if (offset &lt; 0 || count &lt; 0   *         || offset + count &gt; data.length)   *         (while unspecified, this is a StringIndexOutOfBoundsException)   * @see #String(char[], int, int)   */  public static String copyValueOf(char[] data, int offset, int count)  {    String r = new String ();    r.init(data, offset, count, false);    return r;  }  /**   * Returns a String representation of a character array. Subsequent   * changes to the array do not affect the String.   *   * @param data the character array   * @return a String containing the same character sequence as data   * @throws NullPointerException if data is null   * @see #copyValueOf(char[], int, int)   * @see #String(char[])   */  public static String copyValueOf(char[] data)  {    return copyValueOf (data, 0, data.length);  }  /**   * Returns a String representing a boolean.   *   * @param b the boolean   * @return "true" if b is true, else "false"   */  public static String valueOf(boolean b)  {    return b ? "true" : "false";  }  /**   * Returns a String representing a character.   *   * @param c the character   * @return String containing the single character c   */  public static native String valueOf(char c);  /**   * Returns a String representing an integer.   *   * @param i the integer   * @return String containing the integer in base 10   * @see Integer#toString(int)   */  public static native String valueOf(int i);  /**   * Returns a String representing a long.   *   * @param l the long   * @return String containing the long in base 10   * @see Long#toString(long)   */  public static String valueOf(long l)  {    return Long.toString(l);  }  /**   * Returns a String representing a float.   *   * @param f the float   * @return String containing the float   * @see Float#toString(float)   */  public static String valueOf(float f)  {    return Float.toString(f);  }  /**   * Returns a String representing a double.   *   * @param d the double   * @return String containing the double   * @see Double#toString(double)   */  public static String valueOf(double d)  {    return Double.toString(d);  }  /**   * Fetches this String from the intern hashtable. If two Strings are   * considered equal, by the equals() method, then intern() will return the   * same String instance. ie. if (s1.equals(s2)) then   * (s1.intern() == s2.intern()). All string literals and string-valued   * constant expressions are already interned.   *   * @return the interned String   */  public native String intern();  /**   * Return the number of code points between two indices in the   * <code>String</code>.  An unpaired surrogate counts as a   * code point for this purpose.  Characters outside the indicated   * range are not examined, even if the range ends in the middle of a   * surrogate pair.   *   * @param start the starting index   * @param end one past the ending index   * @return the number of code points   * @since 1.5   */  public synchronized int codePointCount(int start, int end)  {    if (start < 0 || end >= count || start > end)      throw new StringIndexOutOfBoundsException();    int count = 0;    while (start < end)      {	char base = charAt(start);	if (base < Character.MIN_HIGH_SURROGATE	    || base > Character.MAX_HIGH_SURROGATE	    || start == end	    || start == count	    || charAt(start + 1) < Character.MIN_LOW_SURROGATE	    || charAt(start + 1) > Character.MAX_LOW_SURROGATE)	  {	    // Nothing.	  }	else	  {	    // Surrogate pair.	    ++start;	  }	++start;	++count;      }    return count;  }  /**   * Returns true iff this String contains the sequence of Characters   * described in s.   * @param s the CharSequence   * @return true iff this String contains s   *   * @since 1.5   */  public boolean contains (CharSequence s)  {    return this.indexOf(s.toString()) != -1;  }  /**   * Returns a string that is this string with all instances of the sequence   * represented by <code>target</code> replaced by the sequence in    * <code>replacement</code>.   * @param target the sequence to be replaced   * @param replacement the sequence used as the replacement   * @return the string constructed as above   */  public String replace (CharSequence target, CharSequence replacement)  {    String targetString = target.toString();    String replaceString = replacement.toString();    int targetLength = target.length();    int replaceLength = replacement.length();        int startPos = this.indexOf(targetString);    StringBuilder result = new StringBuilder(this);        while (startPos != -1)      {        // Replace the target with the replacement        result.replace(startPos, startPos + targetLength, replaceString);        // Search for a new occurrence of the target        startPos = result.indexOf(targetString, startPos + replaceLength);      }    return result.toString();  }  private native void init(char[] chars, int offset, int count,			   boolean dont_copy);  private native void init(byte[] chars, int hibyte, int offset, int count);  private native void init(byte[] chars, int offset, int count, String enc)    throws UnsupportedEncodingException;  private native void init(gnu.gcj.runtime.StringBuffer buffer);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -