This document provides a summary of key Java concepts including keywords, packages, character escape sequences, collections, regular expressions, JAR files, and commonly used tools. It includes a table listing Java keywords with their descriptions and examples. The document is intended to give an overview of core aspects of the Java language.
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
If you are preparing to appear for Oracle Certified Professional Java SE 8 Programmer (OCPJP 8) certification exam, this a reference card (sort of long cheat sheet) meant to help you. You may want to print this reference card for your easy and quick reference when you prepare for your exam.
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
If you are preparing to appear for Oracle Certified Professional Java SE 8 Programmer (OCPJP 8) certification exam, this a reference card (sort of long cheat sheet) meant to help you. You may want to print this reference card for your easy and quick reference when you prepare for your exam.
Java Cheat Sheet includes the following contents:
- Data Types
- Statements
- String, ArrayList and HashMap Methods
- Conversion
- Operators
- Exception Handling
Java Cheat Sheet includes the following contents:
- Data Types
- Statements
- String, ArrayList and HashMap Methods
- Conversion
- Operators
- Exception Handling
MySQL Cheat Sheet includes the following contents:
- Data Types
- Creating and Modifying Databases and Tables
- Syntax of SELECT queries
- Joins
- String functions
- Calculation functions
- Matching data
In this cheat sheet, you can find object oriented programming concept's fundamentals very easily. Some topics has very details explanations that could be very helpful those who is in entry level in java mostly object oriented world.
Bash Cheat Sheet -- Bash History Cheat SheetPeter Krumins
Made at http://www.catonmat.net
This cheat sheet includes history editing keyboard shortcuts (emacs and vi mode), history expansion summary - event designators, word designators and modifiers, shell special variables and `shopt’ options to modify history behavior, examples.
Visit http://www.catonmat.net for more cheat sheets!
Developing Applications with MySQL and Java for beginnersSaeid Zebardast
A presentation about Developing Applications with MySQL and Java for beginners. It includes the following topics:
- Requirements
- MySQL Data Definitions
- Java Classes
- MySQL Connector (JDBC)
- Define Methods
- Compile and Run
This presentation introduces Web Components. It includes the following topics:
0. What's Web Component?
1. Templates
2. Shadow DOM
3. Custom Elements
4. Imports
5. How to use them
6. Browser compatibilities.
In Java 9, Garbage First Garbage Collector (G1 GC) will be the default GC. This presentation makes an effort to help Hotspot VM users to understand the concept of G1 GC as well as provides some tuning advice.
24 Books You've Never Heard Of - But Will Change Your LifeRyan Holiday
For the last five years, I’ve tried to do just that on my popular monthly reading list email. I’ve recommended hundreds of amazing, life-changing books to tens of thousands of people:
http://www.ryanholiday.net/reading-newsletter/
20 Quotes To Turn Your Obstacles Into OpportunitiesRyan Holiday
Adapted from "The Obstacle Is The Way: The Timeless Art of Turning Trials into Triumph" by Ryan Holiday
http://www.amazon.com/exec/obidos/ASIN/1591846358/ryanholnet-20
We spend more time working than doing anything else in life. Yet for too many people, the experience of work is demotivating and dehumanizing.
I don’t think it has to be this way, and I’m willing to bet you don’t either.
At Google, we’ve learned a ton about what makes for an enjoyable and productive workplace. We’re not alone – lots of other companies, ranging from grocers (e.g., Wegmans) to textile companies (e.g., the Brandix Group) to Brooklyn delis (e.g., Russ & Daughters), as well as academics and scientists, have learned the same simple truth: there are straightforward things we can do to make work better.
My new book, "Work Rules!", is an attempt to bring this together and offer you practical tools to improve work, no matter what you do. Check out this visual preview of the book and visit www.workrules.net if you’d like to pick up a copy or learn more!
This presentation was presented at OSS camp in New Delhi. It deals with the basics of Scala language and how we can use it to build scalable Applications
Mahika Tutorials sharing PPT slide for core java programming language. Go threw this slide and visit our YouTube page too
https://www.youtube.com/c/mahikatutorials
Paper: SCOTCH: Improving Test-to-Code Traceability using Slicing and Conceptual Coupling
Authors: Abdallah Qusef, Gabriele Bavota, Rocco Oliveto, Andrea De Lucia, David Binkley
Session: Research Track Session 3: Dynamic Analysis
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
1. #24
tech facts at your fingertips
Get More Refcardz! Visit refcardz.com
CONTENTS INCLUDE:
Core Java
n
Java Keywords
n
Standard Java Packages
n
Character Escape Sequences
n
Collections and Common Algorithms
n
Regular Expressions
By Cay S. Horstmann
n
JAR Files
Java Keywords, continued
AbOUT CORE JAVA
Keyword Description Example
finally the part of a try block see try
This refcard gives you an overview of key aspects of the Java that is always executed
language and cheat sheets on the core library (formatted float the single-precision float oneHalf = 0.5F;
output, collections, regular expressions, logging, properties) floating-point type
as well as the most commonly used tools (javac, java, jar). for a loop type for (int i = 10; i >= 0; i--)
System.out.println(i);
for (String s : line.split("s+"))
System.out.println(s);
Note: In the “generalized” for loop, the expression
JAVA KEywORDS after the : must be an array or an Iterable
goto not used
Keyword Description Example if a conditional statement if (input == 'Q')
System.exit(0);
abstract an abstract class or abstract class Writable { else
method public abstract void write(Writer out); more = true;
public void save(String filename) { ... }
implements defines the interface(s) class Student
} implements Printable {
that a class implements
...
assert with assertions enabled, assert param != null; }
throws an error if Note: Run with -ea to enable assertions
condition not fulfilled import imports a package import java.util.ArrayList;
import com.dzone.refcardz.*;
boolean the Boolean type with boolean more = false;
instanceof tests if an object is an if (fred instanceof Student)
values true and false value = ((Student) fred).getId();
instance of a class
break breaks out of a switch while ((ch = in.next()) != -1) { Note: null instanceof T is always false
or loop if (ch == 'n') break;
process(ch); int the 32-bit integer type int value = 0;
}
interface an abstract type with interface Printable {
Note: Also see switch methods that a class can void print();
www.dzone.com
}
byte the 8-bit integer type byte b = -1; // Not the same as 0xFF implement
Note: Be careful with bytes < 0 long the 64-bit long integer long worldPopulation = 6710044745L;
type
case a case of a switch see switch
native a method implemented
catch the clause of a try block see try by the host system
catching an exception
new allocates a new object Person fred = new Person("Fred");
char the Unicode character char input = 'Q'; or array
type
null a null reference Person optional = null;
class defines a class type class Person {
package a package of classes package com.dzone.refcardz;
private String name;
public Person(String aName) { private a feature that is see class
name = aName;
accessible only by
}
public void print() { methods of this class
System.out.println(name);
}
protected a feature that is accessible class Student {
only by methods of this protected int id;
} ...
class, its children, and
}
const not used other classes in the same
package →
continue continues at the end of while ((ch = in.next()) != -1) {
a loop if (ch == ' ') continue;
process(ch);
}
default the default clause of a
switch
see switch Get More Refcardz
(They’re free!)
do the top of a do/while do {
loop ch = in.next();
} while (ch == ' '); n Authoritative content
double the double-precision double oneHalf = 0.5; n Designed for developers
floating-number type
n Written by top experts
else the else clause of an if see if
statement n Latest tools & technologies
Core Java
enum an enumerated type enum Mood { SAD, HAPPY }; n Hot tips & examples
extends defines the parent class class Student extends Person {
n Bonus content online
private int id;
of a class
public Student(String name, int anId) { ... }
n New issue every 1-2 weeks
public void print() { ... }
}
Subscribe Now for FREE!
final a constant, or a class or public static final int DEFAULT_ID = 0;
method that cannot be Refcardz.com
overridden
DZone, Inc. | www.dzone.com
2. 2
Core Java
tech facts at your fingertips
Java Keywords, continued
OpERATOR pRECEDENCE
Keyword Description Example
public a feature that is see class
accessible by methods Operators with the Notes
of all classes same precedence
return returns from a method int getId() { return id; } [] . () (method call) Left to right
short the 16-bit integer type short skirtLength = 24;
! ~ ++ -- + (unary) – Right to left ~ flips each bit of a number
static a feature that is public class WriteUtil { (unary) () (cast) new
unique to its class, not public static void write(Writable[] ws,
String filename); * / % Left to right Be careful when using % with negative
to objects of its class
public static final String DEFAULT_EXT = ".dat"; numbers. -a % b == -(a % b), but a
}
% -b == a % b. For example, -7 % 4
strictfp Use strict rules == -3, 7 % -4 == 3.
for floating-point
computations + - Left to right
super invoke a superclass public Student(String name, int anId) { << >> >>> Left to right >> is arithmetic shift (n >> 1 == n / 2 for
constructor or method super(name); id = anId; positive and negative numbers), >>> is logical
}
shift (adding 0 to the highest bits). The right
public void print() { hand side is reduced modulo 32 if the left hand
super.print(); side is an int or modulo 64 if the left hand side
System.out.println(id);
}
is a long. For example, 1 << 35 == 1 << 3.
switch a selection statement switch (ch) { < <= > >= instanceof Left to right null instanceof T is always false
case 'Q':
case 'q': == != Left to right Checks for identity. Use equals to check for
more = false; break;
structural equality.
case ' ';
break;
default:
& Left to right Bitwise AND; no lazy evaluation with bool
process(ch); break; arguments
}
Note: If you omit a break, processing continues ^ Left to right Bitwise XOR
with the next case.
| Left to right Bitwise OR; no lazy evaluation with bool
synchronized a method or code public synchronized void addGrade(String gr) { arguments
block that is atomic to grades.add(gr);
a thread && Left to right
}
this the implicit argument public Student(String id) {this.id = id;} || Left to right
of a method, or a public Student() { this(""); }
constructor of this class ?: Right to left
throw throws an exception if (param == null) = += -= *= /= %= &= Right to left
throw new IllegalArgumentException(); |= ^= <<= >>= >>>=
throws the exceptions that a public void print()
method can throw throws PrinterException, IOException
transient marks data that should class Student {
private transient Data cachedData;
pRImITIVE TypES
not be persistent
...
}
Type Size Range Notes
try a block of code that try {
traps exceptions try {
fred.print(out);
int 4 bytes –2,147,483,648 to 2,147,483, 647 The wrapper type is Integer.
} catch (PrinterException ex) { (just over 2 billion) Use BigInteger for arbitrary
ex.printStackTrace(); precision integers.
}
} finally { short 2 bytes –32,768 to 32,767
out.close();
} long 8 bytes –9,223,372,036,854,775,808 to Literals end with L (e.g. 1L).
void denotes a method public void print() { ... } 9,223,372,036,854,775,807
that returns no value byte 1 byte –128 to 127 Note that the range is not
volatile ensures that a field is class Student { 0 ... 255.
coherently accessed private volatile int nextId;
by multiple threads ... float 4 bytes approximately Literals end with F (e.g. 0.5F)
} ±3.40282347E+38F (6–7
while a loop while (in.hasNext()) significant decimal digits)
process(in.next()); double 8 bytes approximately Use BigDecimal for arbitrary
±1.79769313486231570E+308 precision floating-point
(15 significant decimal digits) numbers.
STANDARD JAVA pACKAgES char 2 bytes u0000 to uFFFF The wrapper type is
Character. Unicode
java.applet Applets (Java programs that run inside a web page) characters > U+FFFF require
two char values.
java.awt Graphics and graphical user interfaces
boolean true or false
java.beans Support for JavaBeans components (classes with properties and
event listeners)
java.io Input and output
Legal conversions between primitive types
Dotted arrows denote conversions that may lose precision.
java.lang Language support
java.math Arbitrary-precision numbers
java.net Networking
java.nio “New” (memory-mapped) I/O
java.rmi Remote method invocations
java.security Security support
java.sql Database support
java.text Internationalized formatting of text and numbers
java.util Utilities (including data structures, concurrency, regular expressions,
and logging)
DZone, Inc. | www.dzone.com
3. 3
Core Java
tech facts at your fingertips
COLLECTIONS AND COmmON ALgORIThmS FORmATTED OUTpUT wITh printf
ArrayList An indexed sequence that grows and shrinks dynamically Typical usage
LinkedList An ordered sequence that allows efficient insertions and removal at
any location System.out.printf("%4d %8.2f", quantity, price);
ArrayDeque A double-ended queue that is implemented as a circular array String str = String.format("%4d %8.2f", quantity, price);
HashSet An unordered collection that rejects duplicates Each format specifier has the following form. See the tables for
TreeSet A sorted set flags and conversion characters.
EnumSet A set of enumerated type values
LinkedHashSet A set that remembers the order in which elements were inserted
PriorityQueue A collection that allows efficient removal of the smallest element
HashMap A data structure that stores key/value associations
TreeMap A map in which the keys are sorted
EnumMap A map in which the keys belong to an enumerated type
LinkedHashMap A map that remembers the order in which entries were added
WeakHashMap A map with values that can be reclaimed by the garbage collector if
they are not used elsewhere Flags
IdentityHashMap A map with keys that are compared by ==, not equals
Flag Description Example
+ Prints sign for positive and negative numbers +3333.33
Common Tasks
space Adds a space before positive numbers | 3333.33|
List<String> strs = new ArrayList<String>(); Collect strings
0 Adds leading zeroes 003333.33
strs.add("Hello"); strs.add("World!"); Add strings
- Left-justifies field |3333.33 |
for (String str : strs) System.out.println(str); Do something with all elements
in the collection
( Encloses negative number in parentheses (3333.33)
Iterator<String> iter = strs.iterator(); Remove elements that match a
, Adds group separators 3,333.33
while (iter.hasNext()) { condition. The remove method
String str = iter.next();
# (for f format) Always includes a decimal point 3,333.
if (someCondition(str)) iter.remove();
removes the element returned by
the preceding call to next. # (for x or o Adds 0x or 0 prefix 0xcafe
}
format)
strs.addAll(strColl); Add all strings from another
collection of strings
$ Specifies the index of the argument to be formatted; 159 9F
for example, %1$d %1$x prints the first argument in
strs.addAll(Arrays.asList(args)) Add all strings from an array of decimal and hexadecimal
strings. Arrays.asList makes a
List wrapper for an array
< Formats the same value as the previous specification; 159 9F
for example, %d %<x prints the same number in decimal
strs.removeAll(coll); Remove all elements of another and hexadecimal
collection. Uses equals for
comparison
Conversion characters
if (0 <= i && i < strs.size()) { Get or set an element at a
str = strs.get(i); specified index
strs.set(i, "Hello"); Conversion Description Example
} Character
strs.insert(i, "Hello"); Insert or remove an element at d Decimal integer 159
str = strs.remove(i); a specified index, shifting the x Hexadecimal integer 9f
elements with higher index values
o Octal integer 237
String[] arr = new String[strs.size()]; Convert from collection to array
strs.toArray(arr); f Fixed-point floating-point 15.9
String[] arr = ...; Convert from array to list. Use e Exponential floating-point 1.59e+01
List<String> lst = Arrays.asList(arr); the varargs form to make a small
lst = Arrays.asList("foo", "bar", "baz"); g General floating-point (the shorter of e and f)
collection.
List<String> lst = ...; Sort a list by the natural order of a Hexadecimal floating-point 0x1.fccdp3
lst.sort(); the elements, or with a custom
lst.sort(new Comparator<String>() { s String Hello
public int compare(String a, String b) {
comparator.
return a.length() - b.length(); c Character H
}
}
b boolean true
Map<String, Person> map = new Make a map that is traversed in h Hash code 42628b2
LinkedHashMap<String, Person>(); insertion order (requires hashCode tx Date and time See the next table
for key type). Use a TreeMap to
traverse in sort order (requires that % The percent symbol %
key type is comparable). n The platform-dependent line separator
for (Map.Entry<String, Person> entry : Iterate through all entries of the
map.entrySet()) { map
String key = entry.getKey();
Person value = entry.getValue();
... FORmATTED OUTpUT wITh MessageFormat
}
Person key = map.get(str); // null if not found Get or set a value for a given key
map.put(key, value); Typical usage:
String msg = MessageFormat.format("On {1, date,
long}, a {0} caused {2,number,currency} of damage.",
ChARACTER ESCApE SEqUENCES "hurricane", new GregorianCalendar(2009, 0, 15).
getTime(), 1.0E8);
b backspace u0008
t tab u0009
Yields "On January 1, 1999, a hurricane caused
n newline u000A $100,000,000 of damage"
f form feed u000C n The nth item is denoted by {n,format,subformat} with
r carriage return u000D
optional formats and subformats shown below
" double quote
n {0} is the first item
' single quote
backslash
n The following table shows the available formats
uhhhh (hhhh is a hex number between 0000 and FFFF) The UTF-16 code point with value hhhh n Use single quotes for quoting, for example '{' for a literal
ooo (ooo is an octal number between 0 and 377) The character with octal value ooo left curly brace
Note: Unlike in C/C++, xhh is not allowed n Use '' for a literal single quote →
DZone, Inc. | www.dzone.com
4. 4
Core Java
tech facts at your fingertips
Formatted Output with MessageFormat, continued Regular Expression Syntax, continued
Format Subformat Example Boundary Matchers
number none 1,234.567 ^ $ Beginning, end of input (or beginning, end of line in multiline mode)
integer 1,235 b A word boundary
currency $1,234.57
B A nonword boundary
percent 123,457%
A Beginning of input
z End of input
date none or medium Jan 15, 2009
Z End of input except final line terminator
short 1/15/09
G End of previous match
long January 15, 2009
Quantifiers
full Thursday, January 15, 2009
X? Optional X
time none or medium 3:45:00 PM
X* X, 0 or more times
short 3:45 PM
X+ X, 1 or more times
long 3:45:00 PM PST
X{n} X{n,} X{n,m} X n times, at least n times, between n and m times
full 3:45:00 PM PST
Quantifier Suffixes
choice List of choices, separated by |. Each choice has no house
? Turn default (greedy) match into reluctant match
n a lower bound (use -u221E for -∞)
n a relational operator: < for “less than”, # or
one house + Turn default (greedy) match into reluctant match
u2264 for ≤ Set Operations
5 houses
n a message format string
XY Any string from X, followed by any string from Y
For example, {1,choice,0#no houses|1#one
X |Y Any string from X or Y
house|2#{1} houses}
Grouping
(X) Capture the string matching X as a group
REgULAR ExpRESSIONS g The match of the gth group
Escapes
Common Tasks c The character c (must not be an alphabetic character)
Q . . . E Quote . . . verbatim
String[] words = str.split("s+"); Split a string along white
space boundaries (? . . . ) Special construct— see API notes of Pattern class
Pattern pattern = Pattern.compile("[0-9]+"); Replace all matches.
Matcher matcher = pattern.matcher(str); Here we replace all digit Predefined Character Class Names
String result = matcher.replaceAll("#"); sequences with a #.
Lower ASCII lower case [a-z]
Pattern pattern = Pattern.compile("[0-9]+"); Find all matches.
Matcher matcher = pattern.matcher(str); Upper ASCII upper case [A-Z]
while (matcher.find()) { Alpha ASCII alphabetic [A-Za-z]
process(str.substring(matcher.start(), matcher.end()));
}
Digit ASCII digits [0-9]
Alnum ASCII alphabetic or digit [A-Za-z0-9]
Pattern pattern = Pattern.compile( Find all groups (indicated
"(1?[0-9]):([0-5][0-9])[ap]m"); by parentheses in the XDigit Hex digits [0-9A-Fa-f]
Matcher matcher = pattern.matcher(str); pattern). Here we find
Print or Graph Printable ASCII character [x21-x7E]
the hours and minutes
for (int i = 1; i <= matcher.groupCount(); i++) {
in a date. Punct ASCII nonalpha or digit [p{Print}&&P{Alnum}]
process(matcher.group(i));
}
ASCII All ASCII [x00-x7F]
Cntrl ASCII Control character [x00-x1F]
Regular Expression Syntax Blank Space or tab [ t]
Space Whitespace [ tnrf0x0B]
Characters
javaLowerCase Lower case, as determined by Character.isLowerCase()
c The character c
javaUpperCase Upper case, as determined by Character.isUpperCase()
unnnn, xnn, The code unit with the given hex or octal value
0n, 0nn, javaWhitespace White space, as determined by Character.isWhiteSpace()
0nnn
javaMirrored Mirrored, as determined by Character.isMirrored()
t, n, r, The control characters tab, newline, return, form feed, alert, and escape
InBlock Block is the name of a Unicode character block, with spaces
f, a, e
removed, such as BasicLatin or Mongolian.
cc The control character corresponding to the character c
Category or InCategory Category is the name of a Unicode character category such
Character Classes as L (letter) or Sc (currency symbol).
[C1C 2 . . .] Union: Any of the characters represented by C1C 2 , . . .
The Ci are characters, character ranges c1-c 2, or character classes. Flags for matching
Example: [a-zA-Z0-9_]
The pattern matching can be adjusted with flags, for example:
[^C1C2 . . .] Complement: Characters not represented by any of C1C 2 , . . .
Example: [^0-9] Pattern pattern = Pattern.compile(patternString,
[C1&& C2 && . . .] Intersection: Characters represented by all of C1C 2 , . . . Pattern.CASE_INSENSITIVE + Pattern.UNICODE_CASE)
Example: [A-f&&[^G-`]]
Flag Description
Predefined Character Classes
CASE_INSENSITIVE Match characters independently of the letter case. By default,
. Any character except line terminators (or any character if the DOTALL this flag takes only US ASCII characters into account.
flag is set)
UNICODE_CASE When used in combination with CASE_INSENSITIVE, use Unicode
d A digit [0-9] letter case for matching.
D A nondigit [^0-9] MULTILINE ^ and $ match the beginning and end of a line, not the entire input.
s A whitespace character [ tnrfx0B] UNIX_LINES Only 'n' is recognized as a line terminator when matching ^
and $ in multiline mode.
S A nonwhitespace character
DOTALL When using this flag, the . symbol matches all characters,
w A word character [a-zA-Z0-9_] including line terminators.
W A nonword character CANON_EQ Takes canonical equivalence of Unicode characters into account.
For example, u followed by ¨ (diaeresis) matches ü.
p{name} A named character class—see table below
LITERAL The input string that specifies the pattern is treated as a sequence
P{name} The complement of a named character class of literal characters, without special meanings for . [ ] etc.
DZone, Inc. | www.dzone.com
5. 5
Core Java
tech facts at your fingertips
LOggINg pROpERTy FILES
Common Tasks n Contain name/value pairs, separated by =, :, or whitespace
Logger logger = Get a logger for a category n Whitespace around the name or before the start of the
Logger.getLogger("com.mycompany.myprog.mycategory");
logger.info("Connection successful."); Logs a message of level FINE.
value is ignored
Available levels are SEVERE, n Lines can be continued by placing an as the last character;
WARNING,INFO,CONFIG,FINE,
FINER, FINEST, with leading whitespace on the continuation line is ignored
corresponding methods severe,
warning, and so on. button1.tooltip = This is a long
logger.log(Level.SEVERE, "Unexpected exception", Logs the stack trace of a tooltip text.
throwable); Throwable
logger.setLevel(Level.FINE); Sets the logging level to FINE. n t n f r uxxxx escapes are recognized (but not b
By default, the logging level is
INFO, and less severe logging
or octal escapes)
messages are not logged. n Files are assumed to be encoded in ISO 8859-1; use
Handler handler = new FileHandler("%h/myapp.log", Adds a file handler for saving the
SIZE_LIMIT, LOG_ROTATION_COUNT);
native2ascii to encode non-ASCII characters into
log records in a file. See the table
handler.setFormatter(new SimpleFormatter()); below for the naming pattern. This Unicode escapes
logger.addHandler(handler); handler uses a simple formatter
instead of the XML formatter that n Blank lines and lines starting with # or ! are ignored
is the default for file handlers.
Typical usage:
Logging Configuration Files
Properties props = new Properties();
The logging configuration can be configured through a logging
props.load(new FileInputStream("prog.properties"));
configuration file, by default jre/lib/logging.properties. String value = props.getProperty("button1.tooltip");
Another file can be specified with the system property java. // null if not present
util.logging.config.file when starting the virtual machine.
(Note that the LogManager runs before main.) Also used for resource bundles:
ResourceBundle bundle = ResourceBundle.getBundle("prog");
Configuration Property Description Default
// Searches for prog_en_US.properties,
loggerName.level The logging level of the logger by the None; the logger
given name inherits the handler // prog_en.properties, etc.
from its parent String value = bundle.getString("button1.tooltip");
handlers A whitespace or comma-separated list java.util.logging.
of class names for the root logger. An ConsoleHandler
instance is created for each class name,
using the default constructor.
JAR FILES
loggerName.handlers A whitespace or comma-separated list None
of class names for the given logger n Used for storing applications, code libraries
loggerName. false if the parent logger's handlers true
useParenthandlers (and ultimately the root logger's
n By default, class files and other resources are stored in
handlers) should not be used ZIP file format
config A whitespace or comma-separated list None
of class names for initialization.
n META-INF/MANIFEST.MF contains JAR metadata
java.util.logging. The default handler level Level.ALL for n META-INF/services can contain service provider
FileHandler.level FileHandler,
Level.INFO for
configuration
java.util.logging.
ConsoleHandler.level ConsoleHandler n Use the jar utility to make JAR files
java.util.logging. The class name of the default filter None
FileHandler.formatter
java.util.logging.
jar Utility Options
ConsoleHandler.formatter
Option Description
java.util.logging. The class name of the default formatter java.util.logging.
FileHandler.formatter XMLFormatter for c Creates a new or empty archive and adds files to it. If any of the specified file
java.util.logging. FileHandler, names are directories, the jar program processes them recursively.
ConsoleHandler.formatter java.util.logging.
C Temporarily changes the directory. For example,
SimpleFormatter for
ConsoleHandler jar cvfC myprog.jar classes *.class
changes to the classes subdirectory to add class files.
java.util.logging. The default encoding default platform
FileHandler.encoding encoding e Creates a Main-Class entry in the manifest
java.util.logging. jar cvfe myprog.jar com.mycom.mypkg.MainClass files
ConsoleHandler.encoding
f Specifies the JAR file name as the second command-line argument. If this
java.util.logging. The default limit for rotating log files, 0 (No limit), but set parameter is missing, jar will write the result to standard output (when creating a
FileHandler.limit in bytes to 50000 in jre/lib/ JAR file) or read it from standard input (when extracting or tabulating a JAR file).
logging.properties
i Creates an index file (for speeding up lookups in a large archive)
java.util.logging. The default number of rotated log files 1
FileHandler.count m Adds a manifest to the JAR file.
java.util.logging. The default naming pattern for log files. %h/java%u.log jar cvfm myprog.jar mymanifest.mf files
FileHandler.pattern The following tokens are replaced when
the file is created:
M Does not create a manifest file for the entries.
Token Description t Displays the table of contents.
/ Path separator jar tvf myprog.jar
%t System temporary directory u Updates an existing JAR file
%h Value of user.home system property jar uf myprog.jar com/mycom/mypkg/SomeClass.class
%g The generation number of rotated logs v Generates verbose output.
%u A unique number for resolving
naming conflicts x Extracts files. If you supply one or more file names, only those files are
%% The % character extracted. Otherwise, all files are extracted.
jar xf myprog.jar
java.util.logging. The default append mode for file loggers; false
FileHandler.append true to append to an existing log file O Stores without ZIP compression
DZone, Inc. | www.dzone.com