Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

String.getBytes wierdness

Thread view: 
Scott.R.Lemke@gmail.com - 21 Jun 2006 19:40 GMT
I'm playing around with some of the digesting classes to see if I can't
write a quick file comparer(diff) utility for practice. What I am doing
is taking a string, digesting it, then comparing it to a digest to
another string to see if they are equal(trying to use something along
the lines of the rsync algorithm)

What I came across was that calling getBytes on my strings is not
giving me a consistent result. Successive getByte calls to equivilent,
or even the same, string object are giving me different bytes, which in
turn leads to different digests.

My question is, am I missing something? Is my assumption that calls of
getBytes to equivilent or the exact same string should give the same
byte[] result wrong?
Matt Humphrey - 21 Jun 2006 19:57 GMT
> I'm playing around with some of the digesting classes to see if I can't
> write a quick file comparer(diff) utility for practice. What I am doing
[quoted text clipped - 10 lines]
> getBytes to equivilent or the exact same string should give the same
> byte[] result wrong?

I would expect getBytes to give different results on different platforms
because that method uses the default encoding.  People using getBytes to
send network messages often find the server and client have different
default encoders.  However, I don't see how it would give different results
locally. Whatever getBytes produces must be able to be decoded to the same
source string. Can you post a short code example?

Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/
Scott.R.Lemke@gmail.com - 21 Jun 2006 20:16 GMT
> > I'm playing around with some of the digesting classes to see if I can't
> > write a quick file comparer(diff) utility for practice. What I am doing
[quoted text clipped - 20 lines]
> Cheers,
> Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/

Blah, nevermind, I was looking at memory addresses(knew I should have
listened to my gut). I'm so used to having my print functions know how
to print byte arrays.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.