944,144 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1073
  • Java RSS
Nov 3rd, 2009
0

Java bitwise operation

Expand Post »
i am new to this kind of programming. please help me,.

i got an IP address (32bits) & 3 int (32 X 3 = 96bits) totaling for 128bits i.e., 16bytes.

my problem here is, how to club them all together to create a 16byte string.

please help. thanks in advance
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rameshnerella is offline Offline
2 posts
since Nov 2009
Nov 3rd, 2009
0
Re: Java bitwise operation
cast your IP address as a string if it isn't already. Cast your ints as Int objects, then you'll just need to concatenate them:
Java Syntax (Toggle Plain Text)
  1. Integer one = integerone //your initial value;
  2. Integer two = integertwo
  3. Integer three = integerthree
  4. String myChunk = ipstring.concat(all of your Ints to strings);
Is that what you are asking?
Reputation Points: 31
Solved Threads: 4
Junior Poster in Training
eggmatters is offline Offline
67 posts
since Nov 2008
Nov 3rd, 2009
0
Re: Java bitwise operation
hi eggmatters, thanks for your reply.

but that is not what i am looking for..

this involves some kind of biwise operation.

everything together should become a 16byte string.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rameshnerella is offline Offline
2 posts
since Nov 2009
Nov 3rd, 2009
0
Re: Java bitwise operation
hi eggmatters, thanks for your reply.

but that is not what i am looking for..

this involves some kind of biwise operation.

everything together should become a 16byte string.
Ok, you've lost me there. you are creating strings. Strings are arrays of characters. Characters are bits. Ultimately, anything you code is a 'bitwise' operation. The term 'bitwise operation' explicitly means a comparison of two strings of bytes. Namely XOR and XAND.
Could you be more specific about how your data is typed? is it all character arrays? is it that you need to convert your ints to bytes? Do you want to convert all of your data into a hexidecimal string? Do you have sample code or some type of data structure that you can provide?
Reputation Points: 31
Solved Threads: 4
Junior Poster in Training
eggmatters is offline Offline
67 posts
since Nov 2008
Nov 3rd, 2009
0
Re: Java bitwise operation
By bit operation I think he literally means an operation that directly operates on/manipulates bits. Although the only way I see to do this is to set aside an array of that many bits (via creating an array of 4 integers, which are 32 bits each in Java), then by using some specific operation such as OR (where each int in the array was initialized to 0). Probably not the solution he wants though.
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008
Nov 4th, 2009
0
Re: Java bitwise operation
i think the issue here is how to create a 16byte string.

java Syntax (Toggle Plain Text)
  1. String testString = "quickbrownfoxjum";

this forms a 16byte string.
he is trying to club 32bit ip number & other 3 integers together a string like the above said.

16 letters in the string should represent all the 4 values.

i think, this is what he is looking for....
Reputation Points: 9
Solved Threads: 0
Newbie Poster
mruthyunjaya is offline Offline
5 posts
since Nov 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Java Software Help
Next Thread in Java Forum Timeline: help!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC