Difference Between Serialization Vs Externalization
Dec 4, 2013Difference between Serialization Vs Externalization
View RepliesDifference between Serialization Vs Externalization
View Replieswhat is seriazable.But I am not able to come that why it is used and when should I declare my class(Object) as serialzable and when not?
View Replies View RelatedWhat is serialization in Java ?how to use serialization in Singleton?
View Replies View RelatedI am studying Serialization from the SCJP 6 Kathy Sierra book. I came across this code snippet.
public class Cat implements Serializable {
public static void main(String[] args) {
Cat c = new Cat();
try {
FileOutputStream fs = new FileOutputStream("testSer.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(c);
[code]....
The output is as follows.
files.Cat@4d43691d
files.Cat@7f39ebdb
1) Why are the two hashcodes different?
2) Serialization is supposed to make and identical copy of any object and all its instance variables. So, if the hashcodes are different, are these objects located in different locations in heap?
I am trying to save a state of a big GUI Swing app. I am trying to save the containers (ArrayLists and JPanels too ). But I am recieving an exceptions:
Java Code:
ilian.Quiz.MainApp$5
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1377)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1173)
at java.io.ObjectOutputStream.access$300(ObjectOutputStream.java:162)
[code]...
What is causing it? I guess anonymous classes like new Thread(new Runnable(...) will cause errors.
I'm building GUI and whole app is going to read and rewirte on xml file..
First I make function for read and write and they are working, but now I decide to make one class where I'm going to have get and set.. This is my class wehre I need to read everything from xm class CurrentData {
private String USERNAME = "username";
private String PASSWORD = "password";
private String STATUS = "status";
public String getusername() {
return username;
[Code] ....
Now my idea is when I start app that everything from xml is going to read from xml and trough get is going to show on my interface, when I edit I'm going to save and with function create I'm going to make same xml file with different parameters... how to use serialization...
What is difference between Java Serialization with Inheritance (IS-A Relationship) and Java Serialization with Aggregation (HAS-A Relationship) ....
View Replies View RelatedCan you tell me or give a complete resource of file I/O, serialization!
View Replies View RelatedI'm not sure if that's the right place to ask
But I am a bit confused:
I know that JDK means "Java Development Kit" , but isn't Eclipse the same thing? (so why it's called "IDE"?)
Or maybe Eclipse is a type of JDK?
Or actually JDK and Eclipse are 2 different things
What Is the difference between an ActionListener and an EventHandler ?
button.addActionListener(new ActionListener() {
button.setOnAction(new EventHandler<ActionEvent>() {
exact difference between
1. unread fields
2. unused fileds
in java
I am new to java i dont understand the difference between the abstract and inheritance i mean we use the abstract class with extends with other class name ,even we do that same in the inheritance pls tell me main difference between abstract and inheritance...
View Replies View Relatedhow to program in Javascript, I am wondering what are the advantages and disadvantages OR pros/cons of using JS versus say a language like Java?
View Replies View RelatedI have been tasked with creating an invoice (school assignment). Part of the calculations is creating an interest depending on the amount of days between the current date entered, and invoice date entered (The program prompts the user to enter both the current and invoice dates by asking for the day, month and year).
We are also supposed to set the contructor to a default date of 1/1/1900.. but I don't know how or where to code that.
How to calculate the difference between the CurrentDate and Invoice. I have displayed the dates to the user as follows.
public void displayDate() {
System.out.println("
Today's Date: " + month + "/" + day + "/" + year);
}
public void displayInvDate() {
System.out.println("
Invoice Date: " + invMonth + "/" + invDay + "/" + invYear);
I have just begin to understand collections in Java. I read about the differences between LinkedList and ArrayList but have several doubts on it. I have mentioned them below
1) Why retrieving in ArrayList is faster then LinkedList?. Since both have the get method how does performance differ?.
2) How does re-sizing happens internally in ArrayList when a item is added or removed?. How slow this is compared to the pointer re-shuffling in LinkedList when a item is added or removed?.
I read that InputStream is used for byte based reading it reads 1 byte at a time.And InputStreamReader is used for charcter based reading so it reads one charcter at a time so no need to convert this first to int then read it.Here is reading using InputStream.
input=new FileInputStream("D:/input.txt");
int c;
while((c=input.read())!=-1)
{
System.out.print((char)c);
}
and here is reading using InputStreamReader
input=new FileInputStream("D:/input.txt");
reader=new InputStreamReader(input,"UTF-8");
int c;
while((c=reader.read())!=-1)
{
System.out.print((char)c);
}
so what is difference between InputStream and InputStreamReader in both case i have to use a Int and then read it and at the end if I want to print that data I have to cast that with "(char)c".So what is advantage of using InputStreamReader?
I am new in java. Is there any difference between protected or default when we are talking about one package?
View Replies View RelatedI know jspf is a jsp fragment, but can't a tag also serve as a jsp fragment?
View Replies View RelatedCan explain difference between applet and application?
What are differences in code? How to write application?
What are differences in use? I looked for some answers, but I can't understand what they are talking about.
For example:
Application:
Called as stand-alone application as application can be executed from command prompt
Applet:
Requires some third party tool like a browser to execute
But... While I export applet in exclipse I can use it without any browser, just like application(as I and avarage user knows it).
Ok, I understand difference like "Applets cannot read from or write to hard disk files."
So. What should I use while creating what?
For example, something as simple as windows calc, some 2d simply platformer, some more expanded app, like idk, spotify or media player or whatever?
Since after update 51 of java web applets are nearly useless(as I know, maybe I'm wrong?), what is better?
Can application have GUI or it is only applets thing(stupid question?)?
Where can I find any application tutorial? Everything that I found was for applets. Why?
I know that oracle has released a statement saying that JavaFX will eventually replace Swing. What is the advantage of JavaFX? The new format, using "stage" instead of JFrame, seemed weird. Why is this change necessary? What benefit do we reap from JavaFX that Swing does not have?
View Replies View RelatedIm working on my homework and it mentioned element for one exercise and an index in another, what is the difference, If Any, Between An Element And An Index?
View Replies View RelatedWhat is the difference between float and double?
View Replies View RelatedIf I am making an application using Java SE8 and I use new concepts of JavaSE8 like "Lambda Expressions" and "Default Methods".
After completing my application I give it to client who are using Java Platform less than 8 like Jdk1.7._; then will this application will work fine as it is working on JavaSE8.
a JavaSE8 application works well on Java SE7 platform.
I am reading a java book and find a theory about Interpreter and Compiler. explain different between them?
View Replies View RelatedI know this has been covered before but none of the answers made sense to me. I'm hoping there is an easy way to do this. I have 2 user inputted strings that I have converted to dates and I just want the difference in days.
My code :
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.Scanner;
import java.text.ParseException;
public class DateTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws ParseException {
[Code] ....
Apparently I can't just subtract the dates like I would in VB.
But while searching i came across 2 different implementation.. One is this and other is this , where httpget is used..
So are these same ? When we talk about Restful, is the 2nd implementation valid ?