Learn Java Programming

Java Basics

Properties file in XML in Java

Properties can be stored in XML file. In this article, properties file in XML format is explained. How to store

String index out of range

In Java, “String index out of range” exception is thrown in java substring() & charAt() method. Here, we see the

java.lang.NullPointerException at String.indexOf

The String.indexOf method return the index of the first occurrence of the matched string.If the matched string is passed as

Java String charAt() Method: IndexOutOfBoundsException: String index out of range

The java String.charAt() method returns the character at the given index in a string. If the index value should be

java.io.UnsupportedEncodingException: UTF String.getBytes

The java String.getBytes method converts the specified string to bytes in the encoding format. If the java does not support

java.util.regex.PatternSyntaxException at String.matches

The java String.matches method checks the given string with the specified regular expression. If the string matches the regular expression,

java.util.regex.PatternSyntaxException: Dangling meta character ‘*’ near index 0

The regular expression contains meta characters such as “*”, “+”, “?”. The exception “java.util.regex.PatternSyntaxException: Dangling meta character” will be thrown

java.util.regex.PatternSyntaxException: Unclosed character class near index 0

The regular expression uses the “[ ]” square bracket to match one of the characters with a character in a string. If any character in the square bracket matches the given string, it will be true. The exception “java.util.regex.PatternSyntaxException: Unclosed character class near index” will be thrown if the open square bracket is available without

java.util.regex.PatternSyntaxException: Unclosed group near index 1

The regular expression uses the “( )” round bracket to identify the matching groups in a string. The matched character in the round bracket identified as a match group in a string. The exception “java.util.regex.PatternSyntaxException: Unclosed group near index” will

java.util.regex.PatternSyntaxException: Unmatched closing ‘)’

The regular expression uses the “( )” round bracket to identify the matching groups in a string. The matched character in the round bracket identified as a match group in a string. The exception “java.util.regex.PatternSyntaxException: Unclosed group near index” will