Java CheatSheet
Java CheatSheet
Character
Class constructors
Constructor & Description
Character(char value)
This constructs a newly allocated Character object that represents the specified char value.
Class methods
Method & Description
static int charCount(int codePoint)
This method determines the number of char values needed to represent the specified character (Unicode code
point).
char charValue()
This method returns the value of this Character object.
static int codePointAt(char[] a, int index)
This method returns the code point at the given index of the char array.
static int codePointAt(char[] a, int index, int limit)
This method returns the code point at the given index of the char array, where only array elements with index less
than limit can be used.
static int codePointAt(CharSequence seq, int index)
This method returns the code point at the given index of the CharSequence.
static int codePointBefore(char[] a, int index)
This method returns the code point preceding the given index of the char array.
static int codePointBefore(char[] a, int index, int start)
This method returns the code point preceding the given index of the char array, where only array elements with
index greater than or equal to start can be used.
static int codePointBefore(CharSequence seq, int index)
This method returns the code point preceding the given index of the CharSequence.
static int codePointCount(char[] a, int offset, int count)
This method returns the number of Unicode code points in a subarray of the char array argument
static int codePointCount(CharSequence seq, int beginIndex, int endIndex)
This method returns the number of Unicode code points in the text range of the specified char sequence.
int compareTo(Character anotherCharacter)
This method compares two Character objects numerically.
static int digit(char ch, int radix)
This method returns the numeric value of the character ch in the specified radix.
static int digit(int codePoint, int radix)
This method returns the numeric value of the specified character (Unicode code point) in the specified radix.
boolean equals(Object obj)
This method compares this object against the specified object
static char forDigit(int digit, int radix)
This method determines the character representation for a specific digit in the specified radix.
static byte getDirectionality(char ch)
This method returns the Unicode directionality property for the given character.
static byte getDirectionality(int codePoint)
This method returns the Unicode directionality property for the given character (Unicode code point).
static int getNumericValue(char ch)
This method returns the int value that the specified Unicode character represents.
static int getNumericValue(int codePoint)
This method returns the int value that the specified character (Unicode code point) represents.
static int getType(char ch)
This method returns a value indicating a character's general category.
static int getType(int codePoint)
This method returns a value indicating a character's general category.
int hashCode()
This method returns a hash code for this Character.
static boolean isDefined(char ch)
This method determines if a character is defined in Unicode.
static boolean isDefined(int codePoint)
This method determines if a character (Unicode code point) is defined in Unicode.
static boolean isDigit(char ch)
This method determines if the specified character is a digit.
static boolean isDigit(int codePoint)
This method determines if the specified character (Unicode code point) is a digit.
static boolean isHighSurrogate(char ch)
This method determines if the given char value is a high-surrogate code unit (also known as leading-surrogate code
unit).
static boolean isIdentifierIgnorable(char ch)
This method determines if the specified character should be regarded as an ignorable character in a Java identifier or
a Unicode identifier.
static boolean isIdentifierIgnorable(int codePoint)
This method determines if the specified character (Unicode code point) should be regarded as an ignorable character
in a Java identifier or a Unicode identifier.
static boolean isISOControl(char ch)
This method determines if the specified character is an ISO control character.
static boolean isISOControl(int codePoint)
This method determines if the referenced character (Unicode code point) is an ISO control character.
static boolean isJavaIdentifierPart(char ch)
This method determines if the specified character may be part of a Java identifier as other than the first char acter.
static boolean isJavaIdentifierPart(int codePoint)
This method determines if the character (Unicode code point) may be part of a Java identifier as other than the first
character.
static boolean isJavaIdentifierStart(char ch)
This method determines if the specified character is permissible as the first character in a Java identifier.
static boolean isJavaIdentifierStart(int codePoint)
This method determines if the character (Unicode code point) is permissible as the first character in a Java identifier.
static boolean isLetter(char ch)
This method determines if the specified character is a letter.
static boolean isLetter(int codePoint)
This method determines if the specified character (Unicode code point) is a letter.
static boolean isLetterOrDigit(char ch)
This method determines if the specified character is a letter or digit.
static boolean isLetterOrDigit(int codePoint)
This method determines if the specified character (Unicode code point) is a letter or digit.
static boolean isLowerCase(char ch)
This method determines if the specified character is a lowercase character.
static boolean isLowerCase(int codePoint)
This method determines if the specified character (Unicode code point) is a lowercase character.
static boolean isLowSurrogate(char ch)
This method determines if the given char value is a low-surrogate code unit (also known as trailing-surrogate code
unit).
static boolean isMirrored(char ch)
This method determines whether the character is mirrored according to the Unicode specification.
static boolean isMirrored(int codePoint)
This method determines whether the specified character (Unicode code point) is mirrored according to the Unicode
specification.
static boolean isSpaceChar(char ch)
This method determines if the specified character is a Unicode space character.
String toString()
This method returns a String object representing this Character's value.
static String toString(char c)
This method returns a String object representing the specified char.
static char toTitleCase(char ch)
This method converts the character argument to titlecase using case mapping information from the UnicodeData
file.
static int toTitleCase(int codePoint)
This method converts the character (Unicode code point) argument to titlecase using case mapping information from
the UnicodeData file.
static char toUpperCase(char ch)
This method converts the character argument to uppercase using case mapping information from the UnicodeData
file.
static int toUpperCase(int codePoint)
This method converts the character (Unicode code point) argument to uppercase using case mapping information
from the UnicodeData file.
static Character valueOf(char c)
This method returns a Character instance representing the specified char value.
java.lang.Double
Class constructors
Constructor & Description
Double(double value)
This constructs a newly allocated Double object that represents the primitive double argument.
Double(String s)
This constructs a newly allocated Double object that represents the floating-point value of type double represented
by the string.
Class methods
Method & Description
byte byteValue()
This method returns the value of this Double as a byte (by casting to a byte).
static int compare(double d1, double d2)
This method compares the two specified double values.
int compareTo(Double anotherDouble)
This method compares the two specified double values.
static long doubleToLongBits(double value)
This method returns a representation of the specified floating-point value according to the IEEE 754 floating-point
"double format" bit layout.
static long doubleToRawLongBits(double value)
This method returns a representation of the specified floating-point value according to the IEEE 754 floating-point
"double format" bit layout, preserving Not-a-Number (NaN) values.
double doubleValue()
This method returns a representation of the specified floating-point value according to the IEEE 754 floating-point
"double format" bit layout, preserving Not-a-Number (NaN) values.
boolean equals(Object obj)
This method compares this object against the specified object.
float floatValue()
This method returns the float value of this Double object.
int hashCode()
This method returns a hash code for this Double object.
int intValue()
This method returns the value of this Double as an int (by casting to type int).
boolean isInfinite()
This method returns true if this Double value is infinitely large in magnitude, false otherwise.
static boolean isInfinite(double v)
This method returns true if the specified number is infinitely large in magnitude, false otherwise.
boolean isNaN()
This method returns true if this Double value is a Not-a-Number (NaN), false otherwise.
static boolean isNaN(double v)
This method returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.
static double longBitsToDouble(long bits)
This method returns the double value corresponding to a given bit representation.
long longValue()
This method returns the value of this Double as a long (by casting to type long).
static double parseDouble(String s)
This method returns a new double initialized to the value represented by the specified String, as performed by the
valueOf method of class Double.
short shortValue()
This method returns the value of this Double as a short (by casting to a short).
static String toHexString(double d)
This method returns a hexadecimal string representation of the double argument.
String toString()
This method returns a string representation of this Double object.
static String toString(double d)
This method returns a string representation of the double argument.
static Double valueOf(double d)
This method returns a Double instance representing the specified double value.
static Double valueOf(String s)
This method returns a Double object holding the double value represented by the argument string s.
java.lang.Integer
Class constructors
Constructor & Description
Integer(int value)
This constructs a newly allocated Integer object that represents the specified int value.
Integer(String s)
This constructs a newly allocated Integer object that represents the int value indicated by the String parameter.
Class methods
Method & Description
static int bitCount(int i)
This method returns the number of one-bits in the two's complement binary representation of the specified int
value.
byte byteValue()
This method returns the value of this Integer as a byte.
int compareTo(Integer anotherInteger)
This method compares two Integer objects numerically.
static Integer decode(String nm)
This method decodes a String into an Integer.
double doubleValue()
This method returns the value of this Integer as a double.
boolean equals(Object obj)
This method compares this object to the specified object.
float floatValue()
This method returns the value of this Integer as a float.
static Integer getInteger(String nm)
This method determines the integer value of the system property with the specified name.
static Integer getInteger(String nm, int val)
This method determines the integer value of the system property with the specified name.
static Integer getInteger(String nm, Integer val)
This method returns the integer value of the system property with the specified name.
int hashCode()
This method returns a hash code for this Integer.
static int highestOneBit(int i)
This method returns an int value with at most a single one-bit, in the position of the highest-order ("leftmost") onebit in the specified int value.
int intValue()
This method returns the value of this Integer as an int.
long longValue()
This method returns the value of this Integer as a long.
static int lowestOneBit(int i)
This method returns an int value with at most a single one-bit, in the position of the lowest-order ("rightmost") onebit in the specified int value.
static int numberOfLeadingZeros(int i)
This method returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's
complement binary representation of the specified int value.
static int numberOfTrailingZeros(int i)
This method returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's
complement binary representation of the specified int value.
static int parseInt(String s)
This method parses the string argument as a signed decimal integer.
static int parseInt(String s, int radix)
This method parses the string argument as a signed integer in the radix specified by the second argument.
java.lang.Math
Class methods
Method & Description
static double abs(double a)
This method returns the absolute value of a double value.
static float abs(float a)
This method returns the absolute value of a float value.
static int abs(int a)
This method returns the absolute value of an int value.
static long abs(long a)
This method returns the absolute value of a long value.
static double acos(double a)
This method returns the arc cosine of a value; the returned angle is in the range 0.0 through pi.
static double asin(double a)
This method returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2.
static double atan(double a)
This method returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.
static double atan2(double y, double x)
This method returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r,
theta).
static double cbrt(double a)
This method returns the cube root of a double value.
static double ceil(double a)
This method returns the smallest (closest to negative infinity) double value that is greater than or equal to the
argument and is equal to a mathematical integer.
static double copySign(double magnitude, double sign)
This method returns the first floating-point argument with the sign of the second floating-point argument.
static float copySign(float magnitude, float sign)
This method returns the first floating-point argument with the sign of the second floating-point argument.
static double cos(double a)
This method returns the trigonometric cosine of an angle.
static double cosh(double x)
This method returns the hyperbolic cosine of a double value.
static double exp(double a)
This method returns Euler's number e raised to the power of a double value.
static double expm1(double x)
This method returns ex -1.
static double floor(double a)
This method returns the largest (closest to positive infinity) double value that is less than or equal to the argument
and is equal to a mathematical integer.
static int getExponent(double d)
This method returns the unbiased exponent used in the representation of a double.
static int getExponent(float f)
This method returns the unbiased exponent used in the representation of a float.
static double hypot(double x, double y)
This method returns sqrt(x2 +y2 ) without intermediate overflow or underflow.
static double IEEEremainder(double f1, double f2)
This method computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.
static double log(double a)
This method returns the natural logarithm (base e) of a double value.
static double log10(double a)
This method returns the base 10 logarithm of a double value.
java.lang.String
Class constructors
Constructor & Description
String()
This initializes a newly created String object so that it represents an empty character sequence.
String(byte[] bytes)
This constructs a new String by decoding the specified array of bytes using the platform's default charset.
String(byte[] bytes, Charset charset)
This constructs a new String by decoding the specified array of bytes using the specified charset.
String(byte[] bytes, int offset, int length)
This constructs a new String by decoding the specified subarray of bytes using the platform's default charset
String(byte[] bytes, int offset, int length, Charset charset)
This constructs a new String by decoding the specified subarray of bytes using the specified charset.
String(byte[] bytes, int offset, int length, String charsetName)
This constructs a new String by decoding the specified subarray of bytes using the specified charset.
String(byte[] bytes, String charsetName)
This constructs a new String by decoding the specified array of bytes using the specified charset.
String(char[] value)
This allocates a new String so that it represents the sequence of characters currently contained in the character array
argument.
String(char[] value, int offset, int count)
This allocates a new String that contains characters from a subarray of the character array argument.
String(int[] codePoints, int offset, int count)
This allocates a new String that contains characters from a subarray of the Unicode code point array argument.
String(String original)
This initializes a newly created String object so that it represents the same sequence of characters as the argument;
in other words, the newly created string is a copy of the argument string.
String(StringBuffer buffer)
This allocates a new string that contains the sequence of characters currently contained in the string buffer
argument.
String(StringBuilder builder)
This allocates a new string that contains the sequence of characters currently contained in the string builder
argument.
Class methods
Method & Description
char charAt(int index)
This method returns the char value at the specified index.
int codePointAt(int index)
This method returns the character (Unicode code point) at the specified index.
int codePointBefore(int index)
This method returns the character (Unicode code point) before the specified index.
int codePointCount(int beginIndex, int endIndex)
This method returns the number of Unicode code points in the specified text range of this String.
int compareTo(String anotherString)
This method compares two strings lexicographically.
int compareToIgnoreCase(String str)
This method compares two strings lexicographically, ignoring case differences.
String concat(String str)
This method concatenates the specified string to the end of this string.
boolean contains(CharSequence s)
This method ceturns true if and only if this string contains the specified sequence of char values.
int length()
This method returns the length of this string.
boolean matches(String regex)
This method tells whether or not this string matches the given regular expression.
int offsetByCodePoints(int index, int codePointOffset)
This method returns the index within this String that is offset from the given index by codePointOffset code points.
boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)
This method tests if two string regions are equal with case ignored.
boolean regionMatches(int toffset, String other, int ooffset, int len)
This method tests if two string regions are equal.
String replace(char oldChar, char newChar)
This method returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
String replace(CharSequence target, CharSequence replacement)
This method replaces each substring of this string that matches the literal target sequence with the specified literal
replacement sequence.
String replaceAll(String regex, String replacement)
This method replaces each substring of this string that matches the given regular expression with the given
replacement.
String replaceFirst(String regex, String replacement)
This method replaces the first substring of this string that matches the given regular expression with the given
replacement.
String[] split(String regex)
This method splits this string around matches of the given regular expression.
String[] split(String regex, int limit)
This method splits this string around matches of the given regular expression.
boolean startsWith(String prefix)
This method tests if this string starts with the specified prefix.
boolean startsWith(String prefix, int toffset)
This method tests if the substring of this string beginning at the specified index starts with the specified prefix.
CharSequence subSequence(int beginIndex, int endIndex)
This method returns a new character sequence that is a subsequence of this sequence.
String substring(int beginIndex)
This method returns a new string that is a substring of this string.
String substring(int beginIndex, int endIndex)
This method returns a new string that is a substring of this string.
char[] toCharArray()
This method converts this string to a new character array.
String toLowerCase()
This method converts all of the characters in this String to lower case using the rules of the default locale.
String toLowerCase(Locale locale)
This method converts all of the characters in this String to lower case using the rules of the given Locale.
String toString()
This method returns the string itself.
String toUpperCase()
This method converts all of the characters in this String to upper case using the rules of the default locale.
String toUpperCase(Locale locale)
This method converts all of the characters in this String to upper case using the rules of the given Locale.
String trim()
This method returns a copy of the string, with leading and trailing whitespace omitted.
static String valueOf(boolean b)
This method returns the string representation of the boolean argument.
static String valueOf(char c)
This method returns the string representation of the char argument.
static String valueOf(char[] data)
This method returns the string representation of the char array argument.
java.lang.StringBuilder
Class constructors
Constructor & Description
StringBuilder()
This constructs a string builder with no characters in it and an initial capacity of 16 characters.
StringBuilder(CharSequence seq)
This constructs a string builder that contains the same characters as the specified CharSequence.
StringBuilder(int capacity)
This constructs a string builder with no characters in it and an initial capacity specified by t he capacity argument.
StringBuilder(String str)
This constructs a string builder initialized to the contents of the specified string.
Class methods
Method & Description
StringBuilder append(boolean b)
This method appends the string representation of the boolean argument to the sequence.
StringBuilder append(char c)
This method appends the string representation of the char argument to this sequence.
StringBuilder append(char[] str)
This method appends the string representation of the char array argument to this sequence.
StringBuilder append(char[] str, int offset, int len)
This method appends the string representation of a subarray of the char array argument to this sequence.
StringBuilder append(CharSequence s)
This method appends the specified character sequence to this Appendable.
StringBuilder append(CharSequence s, int start, int end)
This method appends a subsequence of the specified CharSequence to this sequence.
StringBuilder append(double d)
This method appends the string representation of the double argument to this sequence.
StringBuilder append(float f)
This method appends the string representation of the float argument to this sequence.
StringBuilder append(int i)
This method appends the string representation of the int argument to this sequence.
StringBuilder append(long lng)
This method appends the string representation of the long argument to this sequence.
StringBuilder append(Object obj)
This method appends the string representation of the Object argument.
StringBuilder append(String str)
This method appends the specified string to this character sequence.
StringBuilder append(StringBuffer sb)
This method appends the specified StringBuffer to this sequence.
StringBuilder appendCodePoint(int codePoint)
This method appends the string representation of the codePoint argument to this sequence.
int capacity()
This method returns the current capacity.
char charAt(int index)
This method returns the char value in this sequence at the specified index.
int codePointAt(int index)
This method returns the character (Unicode code point) at the specified index.
int codePointBefore(int index)
This method returns the character (Unicode code point) before the specified index.
int codePointCount(int beginIndex, int endIndex)
This method returns the number of Unicode code points in the specified text range of this sequence.
java.util.Arrays
Class methods
Method & Description
static <T> List<T> asList(T... a)
This method returns a fixed-size list backed by the specified array.
static int binarySearch(byte[] a, byte key)
This method searches the specified array of bytes for the specified value using the binary search algorithm.
static int binarySearch(byte[] a, int fromIndex, int toIndex, byte key)
This method searches a range of the specified array of bytes for the specified value using the binary search
algorithm.
static int binarySearch(char[] a, char key)
This method searches the specified array of chars for the specified value using the binary search algorithm.
static int binarySearch(char[] a, int fromIndex, int toIndex, char key)
This method searches a range of the specified array of chars for the specified value using the binary search
algorithm.
static int binarySearch(double[] a, double key)
This method searches the specified array of doubles for the specified value using the binary search algorithm.
static int binarySearch(double[] a, int fromIndex, int toIndex, double key)
This method searches a range of the specified array of doubles for the specified value using the binary search
algorithm.
static int binarySearch(float[] a, float key)
This method searches the specified array of floats for the specified value using the binary search algorithm.
static int binarySearch(float[] a, int fromIndex, int toIndex, float key)
This method searches a range of the specified array of floats for the specified value using the binary search
algorithm.
static int binarySearch(int[] a, int key)
This method searches the specified array of ints for the specified value using the binary search algorithm.
static int binarySearch(int[] a, int fromIndex, int toIndex, int key)
This method searches a range of the specified array of ints for the specified value using the binary search algorithm.
static int binarySearch(long[] a, int fromIndex, int toIndex, long key)
This method searches a range of the specified array of longs for the specified value using the binary search
algorithm.
static int binarySearch(long[] a, long key)
This method searches the specified array of longs for the specified value using the binary search algorithm.
static int binarySearch(Object[] a, int fromIndex, int toIndex, Object key )
This method searches a range of the specified array for the specified object using the binary search algorithm.
static int binarySearch(Object[] a, Object key)
This method searches the specified array for the specified object using the binary search algorithm.
static int binarySearch(short[] a, int fromIndex, int toIndex, short key)
This method searches a range of the specified array of shorts for the specified value using the binary search
algorithm.
static int binarySearch(short[] a, short key)
This method searches the specified array of shorts for the specified value using the binary search algorithm.
static <T> int binarySearch(T[] a, int fromIndex, int toIndex, T key, Comparator<? super T> c)
This method searches a range of the specified array for the specified object using the binary search algorithm.
static <T> int binarySearch(T[] a, T key, Comparator<? super T> c)
This method searches the specified array for the specified object using the binary search algorithm.
static boolean[] copyOf(boolean[] original, int newLength)
This method copies the specified array, truncating or padding with false (if necessary) so the copy has the specified
length.
static byte[] copyOf(byte[] original, int newLength)
This method copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified
length.
java.util.ArrayList
Class constructors
Constructor & Description
ArrayList()
This constructor is used to create an empty list with an initial capacity sufficient to hold 10 elements.
ArrayList(Collection<? extends E> c)
This constructor is used to create a list containing the elements of the specified collection.
ArrayList(int initialCapacity)
This constructor is used to create an empty list with an initial capacity.
Class methods
Method & Description
boolean add(E e)
This method appends the specified element to the end of this list.
void add(int index, E element)
This method inserts the specified element at the specified position in this list.
boolean addAll(Collection<? extends E> c)
This method appends all of the elements in the specified collection to the end of this list, in the order that they are
returned by the specified collection's Iterator
boolean addAll(int index, Collection<? extends E> c)
This method inserts all of the elements in the specified collection into this list, starting at the specified position.
void clear()
This method removes all of the elements from this list.
Object clone()
This method returns a shallow copy of this ArrayList instance.
boolean contains(Object o)
This method returns true if this list contains the specified element.
void ensureCapacity(int minCapacity)
This increases the capacity of this ArrayList.
E get(int index)
This method returns the element at the specified position in this list.
int indexOf(Object o)
This method returns the index of the first occurrence of the specified element in this list, or -1 if this list does not
contain the element.
boolean isEmpty()
This method returns true if this list contains no elements.
int lastIndexOf(Object o)
This method returns the index of the last occurrence of the specified element in this list, or -1 if this list does not
contain the element.
E remove(int index)
This method removes the element at the specified position in this list.
boolean remove(Object o)
This method removes the first occurrence of the specified element from this list, if it is present.
protected void removeRange(int fromIndex, int toIndex)
This method removes from this list all of the elements whose index is between fromIndex(inclusive) and
toIndex(exclusive).
E set(int index, E element)
This method replaces the element at the specified position in this list with the specified element.
int size()
This method returns the number of elements in this list.
Object[] toArray()
This method returns an array containing all of the elements in this list in proper sequence (from first to last element).
java.util.Formatter
Class constructors
Constructor & Description
Formatter()
This constructor constructs a new formatter.
Formatter(Appendable a)
This constructor constructs a new formatter with the specified destination.
Formatter(Appendable a, Locale l)
This constructor constructs a new formatter with the specified destination and locale.
Formatter(File file)
This constructor constructs a new formatter with the specified file.
Formatter(File file, String csn)
This constructor constructs a new formatter with the specified file and charset.
Formatter(File file, String csn, Locale l)
This constructor constructs a new formatter with the specified file, charset, and locale.
Formatter(Locale l)
This constructor constructs a new formatter with the specified locale.
Formatter(OutputStream os)
This constructor constructs a new formatter with the specified output stream.
Formatter(OutputStream os, String csn)
This constructor constructs a new formatter with the specified output stream and charset.
Formatter(OutputStream os, String csn, Locale l)
This constructor constructs a new formatter with the specified output stream, charset, and locale.
Formatter(PrintStream ps)
This constructor constructs a new formatter with the specified print stream.
Formatter(String fileName)
This constructor constructs a new formatter with the specified file name.
Formatter(String fileName, String csn)
This constructor constructs a new formatter with the specified file name and charset.
Formatter(String fileName, String csn, Locale l)
This constructor constructs a new formatter with the specified file name, charset, and locale.
Class methods
Method & Description
void close()
This method closes this formatter.
void flush()
This method flushes this formatter.
Formatter format(Locale l, String format, Object... args)
This method writes a formatted string to this object's destination using the specified locale, format string, and
arguments.
Formatter format(String format, Object... args)
This method writes a formatted string to this object's destination using the specified format string and arguments.
IOException ioException()
This method returns the IOException last thrown by this formatter's Appendable.
Locale locale()
This method returns the locale set by the construction of this formatter.
Appendable out()
This method returns the destination for the output.
String toString()
This method returns the result of invoking toString() on the destination for the output.
java.util.Scanner
Class constructors
Constructor & Description
Scanner(File source)
This constructs a new Scanner that produces values scanned from the specified file.
Scanner(File source, String charsetName)
This constructs a new Scanner that produces values scanned from the specified file.
Scanner(InputStream source)
This constructs a new Scanner that produces values scanned from the specified input stream.
Scanner(InputStream source, String charsetName)
This constructs a new Scanner that produces values scanned from the specified input stream.
Scanner(Readable source)
This constructs a new Scanner that produces values scanned from the specified source.
Scanner(ReadableByteChannel source)
This constructs a new Scanner that produces values scanned from the specified channel.
Scanner(ReadableByteChannel source, String charsetName)
This constructs a new Scanner that produces values scanned from the specified channel.
Scanner(String source)
This constructs a new Scanner that produces values scanned from the specified string.
Class methods
Method & Description
void close()
This method closes this scanner.
Pattern delimiter()
This method returns the Pattern this Scanner is currently using to match delimiters.
String findInLine(Pattern pattern)
This method attempts to find the next occurrence of the specified pattern ignoring delimiters.
String findInLine(String pattern)
This method attempts to find the next occurrence of a pattern constructed from the specified string, ignoring
delimiters.
String findWithinHorizon(Pattern pattern, int horizon)
This method attempts to find the next occurrence of the specified pattern.
String findWithinHorizon(String pattern, int horizon)
This method attempts to find the next occurrence of a pattern constructed from the specified string, ignoring
delimiters.
boolean hasNext()
This method returns true if this scanner has another token in its input.
boolean hasNext(Pattern pattern)
This method returns true if the next complete token matches the specified pattern.
boolean hasNext(String pattern)
This method returns true if the next token matches the pattern constructed from the specified string.
boolean hasNextBigDecimal()
This method returns true if the next token in this scanner's input can be interpreted as a BigDecimal using the
nextBigDecimal() method.
boolean hasNextBigInteger()
This method returns true if the next token in this scanner's input can be interpreted as a BigInteger in the default
radix using the nextBigInteger() method.
boolean hasNextBigInteger(int radix)
This method returns true if the next token in this scanner's input can be interpreted as a BigInteger in the spe cified
radix using the nextBigInteger() method.
boolean hasNextBoolean()
This method returns true if the next token in this scanner's input can be interpreted as a boolean value using a case
insensitive pattern created from the string "true|false".
boolean hasNextByte()
This method returns true if the next token in this scanner's input can be interpreted as a byte value in the default
radix using the nextByte() method.
boolean hasNextByte(int radix)
This method returns true if the next token in this scanner's input can be interpreted as a byte value in the specified
radix using the nextByte() method.
boolean hasNextDouble()
This method returns true if the next token in this scanner's input can be interpreted as a double value using the
nextDouble() method.
boolean hasNextFloat()
This method Returns true if the next token in this scanner's input can be interpreted as a float value using the
nextFloat() method.
boolean hasNextInt()
This method returns true if the next token in this scanner's input can be interpreted as an int value in the default
radix using the nextInt() method.
boolean hasNextInt(int radix)
This method returns true if the next token in this scanner's input can be interpreted as an int value in the specified
radix using the nextInt() method.
boolean hasNextLine()
This method returns true if there is another line in the input of this scanner.
boolean hasNextLong()
This method returns true if the next token in this scanner's input can be interpreted as a long value in the default
radix using the nextLong() method.
boolean hasNextLong(int radix)
This method returns true if the next token in this scanner's input can be interpreted as a long value in the specified
radix using the nextLong() method.
boolean hasNextShort()
This method returns true if the next token in this scanner's input can be interpreted as a short value in the default
radix using the nextShort() method.
boolean hasNextShort(int radix)
This method returns true if the next token in this scanner's input can be interpreted as a short value in the specified
radix using the nextShort() method.
IOException ioException()
This method returns the IOException last thrown by this Scanner's underlying Readable.
Locale locale()
This method returns this scanner's locale.
MatchResult match()
This method returns the match result of the last scanning operation performed by this scanner.
String next()
This method finds and returns the next complete token from this scanner.
String next(Pattern pattern)
This method returns the next token if it matches the specified pattern.
String next(String pattern)
This method returns the next token if it matches the pattern constructed from the specified string.
BigDecimal nextBigDecimal()
This method scans the next token of the input as a BigDecimal.
BigInteger nextBigInteger()
This method Scans the next token of the input as a BigInteger.
BigInteger nextBigInteger(int radix)
This method scans the next token of the input as a BigInteger.
boolean nextBoolean()
This method scans the next token of the input into a boolean value and returns that value.
byte nextByte()
This method scans the next token of the input as a byte.
byte nextByte(int radix)
This method scans the next token of the input as a byte.
double nextDouble()
This method scans the next token of the input as a double.
float nextFloat()
This method scans the next token of the input as a float.
int nextInt()
This method scans the next token of the input as an int.
int nextInt(int radix)
This method scans the next token of the input as an int.
String nextLine()
This method advances this scanner past the current line and returns the input that was skipped.
long nextLong()
This method scans the next token of the input as a long.
long nextLong(int radix)
This method scans the next token of the input as a long.
short nextShort()
This method scans the next token of the input as a short.
short nextShort(int radix)
This method scans the next token of the input as a short.
int radix()
This method returns this scanner's default radix.
void remove()
The remove operation is not supported by this implementation of Iterator.
Scanner reset()
This method resets this scanner.
Scanner skip(Pattern pattern)
This method skips input that matches the specified pattern, ignoring delimiters.
Scanner skip(String pattern)
This method skips input that matches a pattern constructed from the specified string.
String toString()
This method returns the string representation of this Scanner.
Scanner useDelimiter(Pattern pattern)
This method sets this scanner's delimiting pattern to the specified pattern.
Scanner useDelimiter(String pattern)
This method sets this scanner's delimiting pattern to a pattern constructed from the specified String.
Scanner useLocale(Locale locale)
This method sets this scanner's locale to the specified locale.
Scanner useRadix(int radix)
This method Sets this scanner's default radix to the specified radix.
java.util.StringTokenizer
Class constructors
Constructor & Description
StringTokenizer(String str)
This constructor a string tokenizer for the specified string.
StringTokenizer(String str, String delim)
This constructor constructs string tokenizer for the specified string.
StringTokenizer(String str, String delim, boolean returnDelims)
This constructor constructs a string tokenizer for the specified string.
Class methods
Method & Description
int countTokens()
This method calculates the number of times that this tokenizer's nextToken method can be called before it generates
an exception.
boolean hasMoreElements()
This method returns the same value as the hasMoreTokens method.
boolean hasMoreTokens()
This method tests if there are more tokens available from this tokenizer's string.
Object nextElement()
This method returns the same value as the nextToken method, except that its declared return value is Object rather
than String.
String nextToken()
This method returns the next token from this string tokenizer.
String nextToken(String delim)
This method returns the next token in this string tokenizer's string.