Internationalize/ Localize java application using locales/ ResourceBundle (example)

Given a java application supporting different languages like French,German, Korean, Japanese, English etc. We will localize strings for each language in different property files. e.g. String pertaining to English language will be kept in one property file Similarly, String of french language will be kept in french property file. We will load property file depending… Read More »

CopyOnWriteArrayList concurrent collection in java (example)

CopyOnWriteArrayList is thread-safe variant of ArrayList. New copy of underlying array is created when any add, set (or modification) operations performed on CopyOnWriteArrayList. CopyOnWriteArrayList can be visualize as combination of words, COPY + On Write + ArrayList. New copy of underlying array is created, when any write/update/remove operation is performed on CopyOnWriteArrayList. i.e. When any… Read More »

Java Scanner example – read & write contents to/ from file (example)

Scanner is text parser which used to parse primitives & strings using regular expression. Scanner split the input into token using delimiter pattern. Default pattern delimiter is whitespace. We will write content to a file using FileWriter class. Then, we will read content from as file using Scanner class. Scanner class extends object & implements… Read More »

Inter thread communication in java (Example/ PipedInputStream /PipedOutputStream)

Inter thread communication is very common phenomenon. There are many ways to achieve inter thread communication. In current post, we will use pipes to achieve thread communication. Java has set of classes named PipedOutputStream & PipedInputStream to communicate between threads. We will create couple of threaders namely producer & consumer. Producer thread will produce the… Read More »

Page 3 of 4312345...102030...Last »