RSS
 

Archive for the ‘J2SE’ Category

JDBC Intro

05 Apr

in this post, i will list two links explain more and more about JDBC and how your java application to datasource like SQL Server:

http://support.microsoft.com/kb/313100

http://www.jdbc-tutorial.com/

 
No Comments

Posted in J2SE

 

Generating Random Numbers In Java

25 Mar

 
No Comments

Posted in J2SE

 

Serialization & DeSerialization … Note This

23 Mar

in this post, i will summarize Serialization & DeSerialization in java, i am reading this chapter from Java Head First book and i found it very interesting “I am crazy about Head First Series”, i get the following screenshot including all the notes, and @end of my post i implement two methods as example to implement Serialization & DeSerialization in java code…..

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MySerializer
{
public void SerializeObject()
{
ObjectOutputStream objectOutputStream = null;
try
{
FileOutputStream fileOutputStream = new FileOutputStream(“MyFile”);
objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeInt(1);
objectOutputStream.writeInt(2);
objectOutputStream.writeInt(3);
}
catch (FileNotFoundException ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
catch (IOException ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
finally
{
try
{
objectOutputStream.close();
}
catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

public void DeSerializeObject()
{
ObjectInputStream objectInputStream = null;
try
{
FileInputStream fileOutputStream = new FileInputStream(“MyFile”);
objectInputStream = new ObjectInputStream(fileOutputStream);
int x=objectInputStream.readInt();
objectInputStream.readInt();
objectInputStream.readInt();
System.out.println(x);

}
catch (FileNotFoundException ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
catch (IOException ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
finally
{
try
{
objectInputStream.close();
}
catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}

My Reference: Java Head First Book

 

Graphical User Interface @ J2SE

21 Mar

 
No Comments

Posted in J2SE

 
 
 

You need to log in to vote

The blog owner requires users to be logged in to be able to vote for this post.

Alternatively, if you do not have an account yet you can create one here.

Powered by Vote It Up