This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

file Serialization  RSS feed

 
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Serial data is sent one element at a time, like a line of cars on an
assembly line



I read this in Java in 21 days book.But can't understand this.May you explain?
 
lowercase baba
Bartender
Posts: 12627
50
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
serial just means you have one pipe, and everything goes through it one at a time. you send the first bit, then the second, then the third, etc.

parallel means you have multiple pipes, so you can send more than one thing at a time. if you had 8 pipes, you could send each of the bits from a byte all at the same time, and the receiving end could re-assemble them.

 
author
Sheriff
Posts: 23587
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

That "line of cars on an assembly line" seems like a silly analogy to me.

Henry
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I can say:

Stream consist of serial bytes, In serialization, an object became serial of bytes in stream. That's why it called serialization.

Right?
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone comfirm?
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

File OurpurStreams write bytes to a file. ObjectOurputStreams turn
objects into data that can be written to a stream.
So we make a FileOutputStream that lets
us write to a file, and we hook an ObjectOutputStrearn (a chain stream) on the end of it.



Can I say ObjectOutputStrearn is like a filter for FileOutputStream , so then stream write object?
 
Saloon Keeper
Posts: 9224
177
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A question:

At first, Does ObjectOurputStream serialize the object, then the object write on FileOutputStream?
Or Does FileOutputStream creates a stream, Then it's filtered by ObjectOurputStream?
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Think good 00. Each class
does onething well. File OurpurStreams write bytes to a file. ObjectOurputStreams turn
objects into data that can be written to a stream. So we make a FileOutputStream that lets
us write to a file, and we hook an ObjectOutputStrearn (a chain stream) on the end of it.

From �Head hhhhehehh
head first java

It is not still clear, Which one first?
 
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

abalfazl hossein wrote:

Think good 00. Each class
does onething well. File OurpurStreams write bytes to a file. ObjectOurputStreams turn
objects into data that can be written to a stream. So we make a FileOutputStream that lets
us write to a file, and we hook an ObjectOutputStrearn (a chain stream) on the end of it.

From �Head hhhhehehh
head first java

It is not still clear, Which one first?



You use FileOutputStream to write to a file. But for that you would need some data to be written to file. So for that you use ObjectOutputStream that uses the objects to create the data. First you would require an ObjectOutputStream, but to that you need to specify which file the data has to be store- so you also need a FileOutputStream. You are delegating the writing to a file to the FileOutputStream and ObjectOutputStream is concerned with creating the data to be written.

Internally ObjectOutputStream has a private class(and it extends OutputStream) which uses this OutputStream (FileOutputStream) passed in the constructor of ObjectOutputStream.
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate Mohammad

But there is question for



In this code data transfers without usage of object outputstream or dataoutputstream or....

But you told:

You use FileOutputStream to write to a file. But for that you would need some data to be written to file. So for that you use ObjectOutputStream that uses the objects to create the data.

 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use ObjectOutputStream in case of Serialization. And for that you want the data in your objects to be written to the file. In otherwise usual cases you can manually write the data in the objects using FileOutputStream. Consider cases where the objects contain other objects and then that contain other objects- in this case you cannot keep obtaining the data from each instance and then write it to the file. You would need a simpler mechanism and that's where Serialization is used.

And in your example above its a simple case of writing some data to a file. And ObjectOutputStream doesn't come into picture here.
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then ObjectOutputStream is like a person, that gets on a bus to go NW.and Bus is FileOutputStream here,

Or FileOutputStream is like a rail, and ObjectOutputStream is like a diesel wagon.

ObjectOutputStream gets on FileOutputStream and goes to destination.

Good example?
 
Marshal
Posts: 60113
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

abalfazl hossein wrote: . . . Good example?

No
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh.... I guess I understand it...May you tell me what is problem about my example?Thanks!
 
Campbell Ritchie
Marshal
Posts: 60113
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The streams do not take each other anywhere. They send data across themselves, altering the format of those data for their respective destinations.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!