example explanation

example explanation

View Answers

June 6, 2008 at 4:28 PM

Hi friend,

import java.io.*;
import java.util.*;
import java.util.Date;
import java.io.Serializable;

public class SerializableExam implements Serializable {
private Date time;
public SerializableExam(){
time = Calendar.getInstance().getTime();
}
public Date getTime(){
return time;
}
public static void main(String args[]){
System.out.println("Welcome to Roseindia");
String filename = "time.ser";
if(args.length > 0) {
filename = args[0];
}
SerializableExam time = null;
FileInputStream fis = null;
ObjectInputStream in = null;
try {
fis = new FileInputStream(filename);
in = new ObjectInputStream(fis);
time = (SerializableExam)in.readObject();
in.close();
}
catch(IOException ex) {
ex.printStackTrace();
}
catch(ClassNotFoundException ex) {
ex.printStackTrace();
}
// print out restored time
System.out.println("Flattened time: " + time.getTime());
System.out.println();
System.out.println("Current time: " + Calendar.getInstance().getTime());
}
}

----------------------------------------------

import java.io.*;
import java.util.*;

public class FlattenTime {
public static void main(String [] args) {
String filename = "time.ser";
if(args.length > 0) {
filename = args[0];
}
SerializableExam time = new SerializableExam();
FileOutputStream fos = null;
ObjectOutputStream out = null;
try {
fos = new FileOutputStream(filename);
out = new ObjectOutputStream(fos);
out.writeObject(time);
out.close();
}
catch(IOException ex) {
ex.printStackTrace();
}
}
}

---------------------------------------------

Read for more information.

http://www.roseindia.net/java/









Related Tutorials/Questions & Answers:
example explanation - Java Beginners
example explanation  can i have some explanation regarding the program given as serialization xample....  Hi friend, import java.io.*; import java.util.*; import java.util.Date; import java.io.Serializable
explanation
the explanation in internet,but not very clear about it. Thank you
Advertisements
explanation - Java Beginners
/GarbageCollection.shtml http://www.roseindia.net/java/example/java/io/code
Hibernate Disjunction.
This section contains explanation of Hibernate disjunction with example
explanation to your code - Java Beginners
explanation to your code  sir, I am very happy that you have responded to my doubts in no time.Thank you very much.I saw the code u sent.Can i... classes.sir i need your brief explanation on this code and also your guidance.this
huffman code give the explanation for this code
huffman code give the explanation for this code  package bitcompress; class Compress extends BitFilter { private boolean encode_flag = false; private BitFilter next_filter = null; private int value; private
huffman code give the explanation for this code
huffman code give the explanation for this code  package bitcompress; class Compress extends BitFilter { private boolean encode_flag = false; private BitFilter next_filter = null; private int value; private
example
example  example on Struts framework
example
example  example on Struts framework
example
example  i need ex on struts-hibernate-spring intergration example   Struts Spring Hibernate Integration
Pagination example with html code
Pagination example with html code  Hi, could u please provide pagination code with clear cut explanation. Thanks in advance
Java Code Explanation
Java Code Explanation
i need project for shopping cart in struts 1 with the oracle database and give clear explanation for how to execute it in my eclipse
i need project for shopping cart in struts 1 with the oracle database and give clear explanation for how to execute it in my eclipse  i need... explanation for how to execute it in my eclipse and where to copy the files as i am
Hibernate Criteria And Restrictions Example
Criteria And Restrictions for example code and explanation of the program. Check...Hibernate Criteria And Restrictions Example  How to use Criteria And Restrictions in Hibernate? Thanks   I will provide you the example
ajax example
Ajax Example Here is the list of few Ajax examples at RoseIndia.net. Ajax example Ajax example   Hi, Where can I find Ajax example... Example Ajax Login Example Thanks Ajax Tutorials  Collection of top
nsentitydescription example
nsentitydescription example  nsentitydescription example
viewwillappear example
viewwillappear example  i need an example of viewwillappear
Ajax example
Ajax example   Hi, Where can I find Ajax example program? Thanks   Hi, Get it at: Ajax Tutorials First Ajax Example Ajax Login Example Thanks
example code
example code  code for displaying a list from another class on a midlet
array example
array example  giving input from outside for array example
Hibernate Example
This tutorial illustrate an example of hibernate
UIButtonTypeCustom Example
UIButtonTypeCustom Example  Hi, Can anyone provide me example of creating UIButton with UIButtonTypeCustom style? Thanks   Hi, Use following example code: UIButton *button = [UIButton buttonWithType
viewwillappear example
viewwillappear example  Hi, Can anyone share me the example of viewwillappear example in IOS? Thanks   HI, Following code can be used: - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated
ibatis example
ibatis example  Which lib directory should we put the ibatis jar files as given in the example of ibatis
Interceptors Example
Interceptors Example  Could anyone give an example of an interceptor through its usage
structure example
structure example  in the example above what do you call the names student1,student2 and student3   Post the code
uisearchbar example
uisearchbar example  UISearch Bar Example - How to enable UISearch bar on map view application
Vitamio example
Vitamio example  Please Give me Whole Code with Manifest file for vitamio example in Android...for Playing Video in Videoview
NSUserDefaults Example
NSUserDefaults Example  Hi, How to use NSUserDefaults? Can anyone share me the NSUserDefaults example code? Thanks (adsbygoogle... NSUserDefaults Example. Thanks (adsbygoogle = window.adsbygoogle
heightForRowAtIndexPath example
heightForRowAtIndexPath example  Hi, Give me code for heightForRowAtIndexPath example? Thanks   Hi, Please check the thread UITableView heightForRowAtIndexPath. Thanks
DAO Example
DAO Example  Dear Friends Could any one please give me any example of DAO application in struts? Thanks & Regards Rajesh
nofollow example
nofollow example  Hi, Provide me nofollow example code. Thanks   Hi, Please check the thread: How to add nofollow in website link? Thanks
MVC Example
MVC Example  I WANT MVC EXAMPLE PROGRAM using Jsp Servlets and Jdbc with mysql of Insert,update,delete,search. please give the answer in MVC rule
NSNotificationCenter Example
NSNotificationCenter Example  Hi, can anyone help me to understand NSNotificationCenter better ..? If possible then please provide me an example or tutorial of nsnotificationcenter in objective c. Thanks
standardserviceregistrybuilder example
class. But there is no code of standardserviceregistrybuilder example. Do you know... the complete code at Hibernate 4 Hello World: Example of Hello World program. Thanks
Example
Distinct and Limit example in MySQL
Distinct and Limit example in MySQL  Hi, How to use the distinct and limit with SQL query in MySQL? Thanks   Hi, Here is example...) from email where email_count >100; Here is example of limit in MySQL
UIAlertView Example
UIAlertView Example  Hi, Provide me good example of UIAlertView. What is the code of UIAlertView that I can use to display message to the user? ThanksADS_TO_REPLACE_1   Hello, You can use the following code
fgets() example
compilation. ADS_TO_REPLACE_2 Example: <?php $file = fopen("...); ?> In this example, the output will either print the line or return
Example Code
Example Code       Example Code Following are the some of example code with demos :  jQuery blur eventADS_TO_REPLACE_1 jQuery change
uialertview example iphone
uialertview example iphone  Hi, How to write uialertview example iphone code? Thanks   Hi, Please check UIAlertView Example. Thanks
java persistence example
java persistence example  java persistence example
example of function overriding in c++
example of function overriding in c++  require an example of function overriding in c
malloc in c example program
malloc in c example program  What is malloc in c? Please explain the term using an example in C program. Thanks
Dirty Checking In Hibernate Example
Dirty Checking In Hibernate Example  What is the example of Dirty Checking in Hibernate? Give me some of the example code? Thanks
Hibernate Example
This section contains a simple Hibernate 4 example using Annotation with source code. The eclipse id and Apache Tomcat is used in this example
Please..please provide me a good Hibernate in Spring example
, Can anyone please provide me a Hibernate in Spring example with simple explanation... hope the following links would be very useful to you: Hibernate Spring Example Hibernate Spring Integration Spring 3 MVC and Hibernate 3 Example Part 3 Let
ModuleNotFoundError: No module named 'example'
ModuleNotFoundError: No module named 'example'  Hi, My Python... 'example' How to remove the ModuleNotFoundError: No module named 'example... to install padas library. You can install example python with following command
example on struts - Struts
example on struts  i need an example on Struts, any example. Please help me out.  Hi friend, For more information,Tutorials and Examples on Struts visit to : http://www.roseindia.net/struts/ Thanks

Ads