Java Code Example for BufferedOutputStream : write(int b) Method

BufferedOutputStream’s write(int b) method overrides write(int b) method of FilterOutputStream. This method writes the specified byte to this output stream. The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b). Implements the abstract write method of OutputStream. Parameters: b – the byte. Throws: IOException – if …

Read More

Java Code Example for BufferedOutputStream to Write OutputStream

BufferedOutputStream can be setup to write the bytes to the underlying output stream without necessarily causing call to the underlying system for each byte written. BufferedOutputStream class has below two constructor : BufferedOutputStream(OutputStream out) – Creates a new buffered output stream to write data to the specified underlying output stream. BufferedOutputStream(OutputStream out, int size) – …

Read More

Java Code Example for BufferedInputStream : mark() method

BufferedInputStream mark() method marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes. The readlimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated. …

Read More

Java Code for BufferedInputStream : reset() Method Example

BufferedInputStream reset() method repositions the current stream to the position at the time the mark method was called last time on this input stream. If markpos is -1 (no mark has been set or the mark has been invalidated), an IOException is thrown. Otherwise, pos is set equal to markpos. Overrides: reset in class FilterInputStream …

Read More

Java Code Example for BufferedInputStream: skip() method

skip() method of BufferedInputStream class creates a byte array and then repeatedly reads into it until n bytes have been read or the end of the stream has been reached. Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over …

Read More

Java Code Example for BufferedInputStream: close() method

close() method of BufferedInputStream closes the current input stream and releases any system resources associated with the stream. Once the stream has been closed, further read(), available(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Read More

Java Code Example for BufferedInputStream: read(byte[] b,int off,int len) Method

Reads bytes from this byte-input stream into the specified byte array, starting at the given offset. It attempts to read as many bytes as possible by repeatedly invoking the read method of the underlying stream. This iterated read continues until one of the following conditions becomes true: The specified number of bytes have been read, …

Read More

Java Code Example for BufferedInputStream: read() Method

read() method of BufferedInputStream class reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the …

Read More

Java Code Example for BufferedInputStream to read file

BufferedInputStream adds an additionally capability to InputStream by buffering the input. When instance of BufferedInputStream is created, an internal array is created to buffer the input data. As bytes from stream are read or skipped, the internal buffer is refilled as necessary from the contained input stream, many bytes at a time. BufferedInputStream class has …

Read More

Code Example for BufferedInputStream: available() method

BufferedInputStream available() method returns the total count of bytes that can be read or skipped over from the input stream without blocking by next invocation of a method for the input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, …

Read More

Aspect-Oriented Modeling – Google Tech Talk (Video)

In software engineering, aspects are concerns that cut across multiple modules. They can lead to the common problems of concern tangling and scattering: concern tangling is where software concerns are not represented independently of each other; concern scattering is where a software concern is represented in multiple remote places in a software artifact. Although aspect-oriented …

Read More

How to insert XMLType column value in oracle10g using JDBC driver?

Recently while working on the client project, i can came across a situation where i have to insert the XML file as XMLType datatype in Oracle 10g table. I was trying to insert the XML file as CLOB object, but it was giving me some Exception. I tried below options for this Inserting the XML …

Read More

Java Program For Uploading File To SFTP Server using JSch SFTP Put

Java Program For Uploading File To SFTP Server using JSch SFTP Put

Uploading the file to SFTP server is not easy using Java.net API or Apache‘s Commons.net API. Many of you have faced lots of problems using these API. To upload the file SFTP server you have use the JSCH SFTP API, you can download the API from here. In my previous post i have shown how to …

Read More

Java program for Downloading File from SFTP server

Java program for Downloading File from SFTP server

Most of the people face problem to download the file from the SFTP server. Everybody thinks it will be same as FTP in java but its not so. If you are using the Apache Commons.net API then you will find below classes for FTP/FTPS but there is no class available for SFTP FTPClient FTPSClient Let …

Read More

How to Perform dynamic load balancing in Glassfish application server?

GlassFish is a fully Java EE 5-compliant application server with enterprise-ready features available under two OSI-approved licenses. Among many other enterprise-level features, GlassFish provides a very good self-management functionality extendable using the Java Management eXtension (JMX) standard.The GlassFish application server provides good facilities for cluster management and load balancing. Still, sometimes we need to have …

Read More

EARs, WARs, JARs, and Java EE

A Java EE application may contain one or more Java EE components such as EJBs, Web modules, resource adapters, or J2EE application client modules. Each Java EE component can have an associated deployment descriptor — an XML file that describes the component. Java enterprise components are deployed using the Java Archive (JAR) file format, which …

Read More

Servlet and JSP performance tuning

This article describes performance-tuning techniques (PTT) for developing high performance and scalable JSP (JavaServer Pages) pages and servlets. That means building applications that are reasonably and consistently fast, and can scale up to the increasing number of users and/or requests. In this article, I walk you through the practical and proven performance-tuning techniques that will …

Read More

Testing Your Java Code

It cannot be said enough that testing is the most important part of the development cycle. Even though I am not a tester (and not trying to push an agenda), I have seen that well written code without adequate test cases is not really something that any developer or team should strive for. And in …

Read More

Spaghetti Code

One always guesses every one knows what a Spaghetti code is – a code which is hard to understand and maintain, a code which everyone is so scared to touch that bug fixes are always quick and dirty, and which makes code further spaghettier. I wonder has anyone thought about spaghetti products. It may not …

Read More