Home Answers Viewqa Java-Beginners example explanation

 
 


niladri saha
example explanation
1 Answer(s)      5 years ago
Posted in : Java Beginners

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 Pages:
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
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
Pagination example with html code
Pagination example with html code  Hi, could u please provide pagination code with clear cut explanation. Thanks in advance
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
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
String indexOf() Method
String indexOf() Method       In this section, you will get the detailed explanation about... 3 C:\unique> Download this example.  
Java Next()
Java Next()       In this section, you will get the detailed explanation about the next() method...; Download this example
Java nextElement()
Java nextElement()       In this section, you will get the detailed explanation about the nextElement... this example
Java hasMoreElement()
Java hasMoreElement()       In this section, you will get the detailed explanation about... C:\unique> Download this example
getRequestURI() Method Of The Request Object
the detailed explanation of the getRequestURI() method of the request object... string after the page name in the URL. This section also provides an example
charAt() Method In Java
charAt() Method In Java       In this section, you will get the detailed explanation about..._work> Download this example
Java remove()
Java remove()       In this section, you will get the detailed explanation about the remove() method...; Download this example
Hibernate Session
This section contains the explanation of hibernate session
Hibernate Select Query
This tutorial contain the explanation of Select clause
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
String indexOf(String str)
String indexOf(String str)       In this section, you will get the detailed explanation about... C:\unique> Download this example
String substring(int beginIndex)
String substring(int beginIndex)       In this section, you will get the detailed explanation about... this example
String lastIndexOf(int ch, int fromIndex)
explanation about the lastindexOf(int ch, int fromIndex) method of String class. We... in the example below which also gives the same output. NOTE: This method returns...(a, 19) = 8 C:\unique> Download this example
String lastIndexOf(String str, int fromIndex)
the detailed explanation about the lastindexOf(String str, int fromIndex) method...; Download this example
String indexOf(int ch)
String indexOf(int ch)       In this section, you will get the detailed explanation about...; Download this example
String indexOf(int ch, int fromIndex)
String indexOf(int ch, int fromIndex)       In this section, you will get the detailed explanation... C:\unique> Download this example
String indexOf(String str, int fromIndex)
explanation about the indexOf(String str, int fromIndex) method of String class. We...; Download this example
Collection Iterate Example
Collection Iterate Example       In this section, you will get the detailed explanation about...; Download this example.  
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
String regionMatches()
; In this section, you will get the detailed explanation about... of the method. Description of the code: As shown in the example a substring... true C:\unique> Download this example
User Login and Registration application
explanation of the application in JSF ( Apache MyFaces) with the combined help of Spring and Hibernate frameworks. This is the best example to understand how to make
Java bigdecimal setScale example
Java bigdecimal setScale example       In this example, bigdecimal class setScale method working... is the explanation. for examle 5E + 2 means 5 * Ten to the power + 2 -55E - 6 means
Java bigdecimal scaleByPowerOfTen example
Java bigdecimal scaleByPowerOfTen example       In this example, bigdecimal class bigdecimal... is the explanation. for examle 6E + 2 means 6 * Ten to the power + 2 -45E - 6 means
String Determining a Character's Unicode Block
explanation about the UnicodeBlock() method of String class. We are going to use... in the example we have taken a Unicode of a character. Then we have applied a method...; Download this example
Struts 2 Login Form Example
Struts 2 Login Form Example tutorial - Learn how to develop Login form.... In this example we are not validating the user against database. In future example I will show you how to validate user against database. You can download the example
Java bigdecimal setScale method example
Java bigdecimal setScale method example       In this example, bigdecimal class setScale method... is the explanation. for examle 5E + 2 means 5 * Ten to the power + 2 -55E
String lastIndexOf(String str)
String lastIndexOf(String str)       In this section, you will get the detailed explanation about... this example
String Concat()
; In this section, you will get the detailed explanation about the Concat.... Description of the code: As shown in the example we have taken two strings i.e. str1...:\unique> Download this example
String getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
; In this section, you will get the detailed explanation about... of the method. Description of the code: As shown in the example we have taken... this example
String intern()
; In this section, you will get the detailed explanation about... of the method. Description of the code: As shown in the example we have created... == str3 true C:\unique> Download this example
Changing the value of Array in Java
array program is provided Java application program about the explanation...;);   } } Download this Example
String lastIndexOf(int ch)
String lastIndexOf(int ch)       In this section, you will get the detailed explanation about...:\unique> Download this example
String substring(int beginIndex, int endIndex)
explanation about the substring(int beginIndex, int endIndex) method of String... this example
String equalsIgnoreCase(String Str)
explanation about the equalsIgnoreCase(String Str) method of String... of the method. Description of the code: As shown in the example below we have taken... this example
Java Word Count - Word Count Example in Java
Java Word Count - Word Count Example in Java       This example illustrates how...) of java.io package. In this example we are using FileReader class of java.io

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.