InputStreamReader & OutputStreamWriter – UTF file (example)

Given the UTF contents, read & write utf contents using InputStreamReader & OutputStreamWriter. We have already discussed similar posts: Read & write UTF file – BufferReader & BufferWriter (using NIO) Read & write contents (without UTF) using InputStreamReader/OutputStreamWriter In this post, we will demonstrate read and write operation with UTF-8 contents. Read write utf file – InputStreamReader & OutputStreamWriter package… Read More »

BufferedReader & BufferedWriter (NIO) – Read & write file (example)

Given a file, read & write file contents using BufferReader & BufferWriter in java. Use java NIO (Non-Blocking or New IO) feature to perform java IO operations. BufferWriter writes to character based stream & BufferReader reads from character based stream, so as to provide efficient writing/reading of characters, arrays, and strings. We have already discussed similar posts: Java IO… Read More »

Read write file using BufferedReader & BufferedWriter in java (example)

BufferWriter, writes to character based stream and BufferReader, reads from character based stream, so as to provide efficient writing/reading of characters, arrays, and strings. BufferReader class: BufferReader class reads text from a character based stream, read methods are as follows: public int read() public int read(char[] cbuf, int off, int len) public String readLine() BufferWriter… Read More »

Read & write file – InputStreamReader & OutputStreamWriter (with example)

InputStreamReader and OutputStreamWriter is character based reader and writer. InputStreamReader converts bytes to characters using specified charset. Read methods are as follows: public int read() public int read(char[] cbuf, int offset, int length) OutputStreamWriter converts characters to bytes using specified charset. Write methods are as follows: public void write(int c) public void write(char[] cbuf, int off,… Read More »

Read & write file using FileInputStream & FileOutputStream in java (example)

FileInputStream and FileOutputStream is byte based reader and writer i.e. FileInputStream and FileOutputStream is used to read and write raw data respectively. FileInputStream reads the contents of file as stream of bytes. The read methods of FileInputStream are. public int read() public int read(byte[] b) public int read(byte[] b, int off, int len) FileOutputStream writes… Read More »

Execution flow Filters & Interceptors in JAX-RS (Jersey & example)

Request response flow in client server paradigm We have shown the request response mechanism of service and client in Fig 1. Request initiated from Client Request data written to transport layer (written to network) Request reaches the Service Request data read from transport channel Service resource process the requests and generate the response Response sent back… Read More »

Program – simulate or generate unchecked exceptions (java & examples)

1. What is unchecked exception in java? Unchecked exceptions are not checked at compiled time. The unchecked exceptions are not forced by compiler to implement. i.e. Its not mandatory to enclose the code with try-catch block. Its purely at programmer’s discretion to catch or throws the unchecked exceptions. We have already discussed about the checked and unchecked… Read More »

Page 20 of 41« First...10...1819202122...3040...Last »