Using Filter Streams in Java

Filter input streams read data from a preexisting input stream such as a FileInputStream and have an opportunity to work with or change the data before it is delivered to the client program. Filter output streams write data to a preexisting output stream such as a FileOutputStream and have an opportunity to work with or . . . →Read More:Using Filter Streams in Java

Share

Using URLConnection in Java

URLConnections are closely related to URLs. Indeed,you get a reference to a URLConnection by using the openConnection() method of an URL object. In many ways,the URL class is only a wrapper around the URLConnection class. URLConnections provide more control over the communication between the client and the server. In particular,URLConnections provide not . . . →Read More:Using URLConnection in Java

Share

Using URL in Java

Here I am going to show example which works with URL. Each URL(Uniform Resource Locator) unambiguously identifies the location of a resource on the Internet. Example shows how to connect to an URL,download its data and show it in console via System.out

import java.io.IOException;import java.io.InputStream;import java.net.MalformedURLException;import java.net.URL;/** * This class . . . →Read More:Using URL in Java

Share

Getting separator symbol in Java

This snippet of code allows to get symbol which represents separator in your file-system:

System.getProperty(“file.separator”);

Share

Writing files in Java

I am going to show example which shows how to write a file in Java. If you want to write some file you should start with FileOutputStream. This class is a concrete subclass of OutputStream. Example:

package tutorial;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;/** * This class shows how to write a . . . →Read More:Writing files in Java

Share

Reading files in Java

I am going to show example which shows how to read a file in Java. If you want to read some file you should start with FileInputStream. This class is a concrete subclass of InputStream. It provides an input stream connected to a particular file. Example:

package tutorial;import java.io.File;import java.io.FileInputStream;import java.io.IOException;import . . . →Read More:Reading files in Java

Share

Getting system root directory in Java

If you are working with file-system in Java,you should understand that your program can run in other types of OS:(Windows,Unix,Linux). These OS has own file-system structure. For example you need to read or write file in Windows,which located at disk C:\,you should write:

File root = new File(“C:\\”);File dir . . . →Read More:Getting system root directory in Java

Share

Getting path to user’s home directory in Java

There is a way to find out path to user’s home folder. Need to get system property:

System.getProperty(“user.home”);

That’s all.

Share

Getting working directory in Java

Sometimes need to know path to your working directory. It is very easy. Here I am going to show snippet of code which helps with this:

System.getProperty(“user.dir”);

It returns String. Call it and you will know your current working directory.

Share

Using InputStream in Java

InputStream is the abstract super class for all input streams. It declares the three basic methods needed to read bytes of data from a stream. It also has methods for closing streams,checking how many bytes of data are available to be read,skipping over input,marking a position in a stream and resetting back . . . →Read More:Using InputStream in Java

Share

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna,tincidunt vitae molestie nec,molestie at mi. Nulla nulla lorem,suscipit in posuere in,interdum non magna.