Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners example explanation

Have Programming Question? Ask it here!
 
 
 


niladri saha
example explanation
1 Answer(s)      6 years and 3 months ago
Posted in : Java Beginners



Advertisement
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
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
Hibernate Disjunction.
This section contains explanation of Hibernate disjunction with example
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
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
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
Hibernate Select Query
This tutorial contain the explanation of Select clause
Hibernate Session
This section contains the explanation of hibernate session
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
array example
array example  giving input from outside for array example
example code
example code  code for displaying a list from another class on a midlet
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
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
NSUserDefaults Example
NSUserDefaults Example  Hi, How to use NSUserDefaults? Can anyone share me the NSUserDefaults example code? Thanks   Hi, Please check the thread NSUserDefaults Example. Thanks
Vitamio example
Vitamio example  Please Give me Whole Code with Manifest file for vitamio example in Android...for Playing Video in Videoview
uisearchbar example
uisearchbar example  UISearch Bar Example - How to enable UISearch bar on map view application
structure example
structure example  in the example above what do you call the names student1,student2 and student3   Post the code
Interceptors Example
Interceptors Example  Could anyone give an example of an interceptor through its usage
ibatis example
ibatis example  Which lib directory should we put the ibatis jar files as given in the example of ibatis
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
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
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
nofollow example
nofollow example  Hi, Provide me nofollow example code. Thanks   Hi, Please check the thread: How to add nofollow in website link? 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
Hibernate Example
This tutorial illustrate an example of hibernate
fgets() example
; Example: <?php $file = fopen("upload.php", "r"...($file). "<br />"; } fclose($file); ?> In this example
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? Thanks   Hello, You can use the following code to display message
Introduction to PHP Array
;value) An example of an array is given below: <?php $first=array('Name...;"; echo $first[18]; ?> Output of the above example is: Rose true  In above example <?php ?> is the delimiter, which
Example Code
Example Code       Example Code Following are the some of example code with demos :  jQuery blur event jQuery change event
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
ServletContextListener example
ServletContextListener example Before going into the details of  ServletContextListener we should understand what is ServletContext. ServletContext is a interface which helps us to communicate with the servlet container
Collection Iterate Example
Collection Iterate Example       In this section, you will get the detailed explanation about...; Download this example.  
basename() example
; The output of this example will print both the base name of the file
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
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
Advertisements
 

 

 

DMCA.com