Objects

F

freesoft_2000

Hi everyone,

Please bear with me as i have a rather silly question.
Lets say i have an object and i want to convert that object say a document
or any other object to an array of bytes. Does anyone know how to do this?

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
J

jan V

Lets say i have an object and i want to convert that object say a document
or any other object to an array of bytes. Does anyone know how to do this?

Serialization via ObjectOutputStream.. only works for Serializable objects
though...
 
R

Roedy Green

Please bear with me as i have a rather silly question.
Lets say i have an object and i want to convert that object say a document
or any other object to an array of bytes. Does anyone know how to do this?

Any help is greatly appreciated

Literally your question is how to I make a silk purse out a sow's ear.

An object has no information in it to speak of, so it can't be so
converted.

However, if you have an object reference to something richer then you
simply cast.

e.g.

Object thing = xxxx;


Dalatian d = (Dalmatian) thing;

However it the object has to have been a Dalmatian (or subclass) all
along.
 
A

Andrew McDonagh

snipped usual Roedy gibberish


The op did say he wanted to change the objects type - but to simply
serialize it to a byte array, which is why Jan V gave the answer.
 
J

John Currier

Andrew said:
snipped usual Roedy gibberish


The op did say he wanted to change the objects type - but to simply
serialize it to a byte array, which is why Jan V gave the answer.

He may have said that, but the language that he used to state the
question was very unclear. When I first read it I assumed that he
mis-typed some words and really wanted to convert an object to a
document. It took some time to figure out what he meant.

Your response was also very unclear in that it said the exact opposite
of what you probably meant.

Referring to Roedy's comments as gibberish doesn't help your argument
when we obviously know better. At least he left his political
commentary out of it!

John
http://schemaspy.sourceforge.net
 
J

jan V

He may have said that, but the language that he used to state the
question was very unclear. When I first read it I assumed that he
mis-typed some words and really wanted to convert an object to a
document. It took some time to figure out what he meant.

Yes, he should write requirements documents. He'll have a long and
prosperous career in our industry...
 
A

Andrew McDonagh

Roedy said:
rather odd you remain totally silent for weeks other than to throw a
broadside insult. Where is your sense of priority?

I tend to read the posts a few days after they appear, which usually
means someone has already answered.

Your post just happened to push the wrong button on me that day - I
apologize for the 'gibberish' remark.
 
R

Roedy Green

I tend to read the posts a few days after they appear, which usually
means someone has already answered.

It is so hard for a beginner to understand Java, that every extra
answer helps. A slight difference in vocabulary can sometimes make all
the difference between understanding and Greek.

Questioners often imagine that they are the sole focus of responses. I
answer for the bigger audience. I use a question merely as a
springboard to present information. Solving the questioner's
particular problem is secondary. I want to educate him and the general
audience of newbies.

That is why I don't think you should focus too sharply on the
questioner's problem. You want to answer in a general enough way
others will recognise the relevance to them.

I want him to learn enough to solve similar questions. I am not into
spoon feeding. My usual approach may be infuriating -- giving the
necessary background info or pointers to it without giving away the
precise solution. However, in the long run I think you end up with
more competent newbies.
 
C

cym tronik

It is so hard for a beginner to understand Java, that every extra
answer helps. A slight difference in vocabulary can sometimes make all
the difference between understanding and Greek.

Questioners often imagine that they are the sole focus of responses. I
answer for the bigger audience. I use a question merely as a
springboard to present information. Solving the questioner's
particular problem is secondary. I want to educate him and the general
audience of newbies.

That is why I don't think you should focus too sharply on the
questioner's problem. You want to answer in a general enough way
others will recognise the relevance to them.

I want him to learn enough to solve similar questions. I am not into
spoon feeding. My usual approach may be infuriating -- giving the
necessary background info or pointers to it without giving away the
precise solution. However, in the long run I think you end up with
more competent newbies.

Your posts have helped me many times Roedy, thanks, keep your style.
cymtronik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Size 6
JDIC?? 2
URLs 3
Strings 17
Uploading 4
What does this mean?? 103
Undo 2
Comments 2

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top