Sunday, May 12, 2013

Access specifiers in java

Access specifiers in java : Access specifiers in java classified into four types for the members. Access specifiers place a very important  role in real time java applications. While developing the application we are defined the members which are  visible outside of the class and which should not visible out side of the package. Suppose in some scenarios  we strictly  hide some of the members which are only visible in side the class and the members which should  not visible any of the...

Java File Output Stream Example

Java File Output Stream Example We can write the file content by using File Output Stream . File Output Stream  writes the stream of raw bytes to the file. File output Stream writes the data by using the write() method. File output Stream Example: import java.io.File; import java.io.FileOutputStream; import java.io.IOException; //write the file content using File OutputStream. public class FileOutputStreamExample { public static void main(String[] args) { FileOutputStream...

Java File Input Stream Example

Java File Input Stream Example We can read the files content by using File Input Stream also. File Input Stream  reads the stream of raw bytes. File Input Stream reads the data by using the read() method. File input Stream Example: import java.io.File; import java.io.FileInputStream; import java.io.IOException; //Read the file content using File InputStream. public class FileInputStreamExample { public static void main(String[] args) { FileInputStream fis = null;//<i>File Input Stream</i>...

Java Constructor Example

Java Constructor Example In java the Objects are created by using the constructor. Once we define a class in the java application, automatically the java compiler provides the default constructor. We can define parameterized constructors also depends on our requirement. Example :  Test test = new Test();  class Test{  } In class Test we haven't defined any constructor, here the java compiler provides the constructor. //default constructor in class Test class Test{   Test(){  } } Constructor name must be same as...

Html5 Examples

Html5 Video Exampl...

Html5 Video Example

Html5 Video Example Html5 Video is very simple to embed video in the web page. It is very simple, to embed the video in our browser we just use the video tag as shown in below example. The controls attribute which adds video controls like volume, play and pause....etc source tag which will give the link to the video files. for src attribute , we should give the path of the media files and for type attribute  will give the media type. you can change the width and height based on webpage look and feel. Below you can find very simple...

Saturday, May 11, 2013

Java BufferedWriter

Java BufferedWriter  BufferedWriter is the class which is under the package java.io. BufferedWriter  Write text to a character-output stream. We can write characters to the file  by using the  write methods . Below i am giving the very simple example, which writes the some text content to the file. if file is there it overwrites the content, if file is not there, it creates one file Java BufferedWriter  Example import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException;...

Java BufferedReader

Java BufferedReader Example BufferedReader is the class which is there in java.io package. Buffered Reader reads the text from a character-input stream. We will pass the FileReader as constructor argument to the  Buffered Reader. BufferedReader reads the file line by line, character, group of characters. Create one .txt file under C directory. I am giving below very straight forward example which reads the file content line by line and print in the console. While iterating to the file, if the pointer reaches to the end of the...

Java String

Java String String class is available under the package java.lang.String. String class is very important class, we almost use most of the places while developing the applications. We no need to import this class in our code, automatically this class is available. String is final class, so the string object can not be modify. String class is immutable object, that means its contents can not be editable. There are lot of methods are there to perform string operations like indexOf, concat,charAt...etc We can create string objects in number...

Java static import

java import static Static import in java is the feature which is available in Java 1.5. This is the best feature if we want to use in some real time scenarios. Before java 1.5 if we want to use the static members in another classes/packages we are using the Classname.MemberName, For Example ClassA.Method(); But With this static import feature, we just define the classname/members starting with import static pkg.class; import static pkg.class.memberNames; In the code we can directly use the static members, if we write static import. But...

Linked HashSet Example

LinkedHashSet Example : LinkedHashSet is the class which is available in java.util package. The main advantage of LinkedHashSet is, it preserves the order of the elements. I mean while iterating the LinkedHashSet  the elements are retrieve in the same order how we insert into it. LinkedHashSet implements the Set interface, it allows the Null values and allows unique elements. LinkedHashSet  has lot of methods which are very much useful. LinkedHashSet which extends the java.util.HashSet Class...

 
Disclaimer : If you find any mistakes / corrections / feedback Please let us know...This website author shall not accept liability or responsibility for any errors, mistakes or misstatements found in this website.