Posts
 
Reputation
Joined
Last Seen
Ranked #343
Strength to Increase Rep
+6
Strength to Decrease Rep
-1
100% Quality Score
Upvotes Received
9
Posts with Upvotes
9
Upvoting Members
6
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
7 Commented Posts
0 Endorsements
Ranked #1K
~14.0K People Reached
Favorite Tags
Member Avatar for neutralfox

[QUOTE=neutralfox;865110]Hello everyone, What is the key in this program? How can I change the key? [/QUOTE] The key is simple a sequence of 16 random bytes created by the KeyGenerator. It's actually the same 16 bytes as returned by getEncoded() -- your raw[] array in this case. If you want …

Member Avatar for JamesCherrill
0
988
Member Avatar for soniagupta98

I assume that "by threads", the assignment means sorting with several threads in parallel. So you need to: - know [URL="http://www.javamex.com/tutorials/threads/"]how to program with threads in Java[/URL] - pick an algorithm that can be parallelised. This essentially means one that uses a "divide and conquer" strategy to work on different …

Member Avatar for finfort
0
133
Member Avatar for ravikiran032

If you want a literal to be a long, you need to suffix it with L: [code] use=1000000000L; [/code] If the literal is small enough to fit in an int, then you can write it as an int (without the "L") and it will automatically be converted to a long. …

Member Avatar for masijade
0
2K
Member Avatar for leverin4

Normally, you get the number of bits dictated by the key size (e.g. 512-bit key = 64 bytes) minus a few bytes (11, I think) of overhead. For the gory details, see the so-called PKCS #1 standard: [url]http://tools.ietf.org/html/rfc3447#page-35[/url] However, if you're worrying about this, you may be doing something wrong! …

Member Avatar for neilcoffey
0
3K
Member Avatar for Magda

Agree about the two ints for number of trains in UP vs DOWN direction. One thing, though-- did your tutor mention to you about [URL="http://www.javamex.com/tutorials/threads/thread_safety.shtml"]thread-safety[/URL]? If you have multiple threads accessing some data (here, multiple Trains accessing variables on the same Track), you need to use some mechanism to make …

Member Avatar for JamesCherrill
0
143
Member Avatar for functionalCode

Essentially, you need to make sure that whatever call is blocking is actually inside the background thread. I don't know the library you're using, but I'm guessing that the call to up.upload() is blocking. (Put some logging on or run in the debugger to find out.)

Member Avatar for BestJewSinceJC
0
110
Member Avatar for smoore

OK, so the basic idea is that you can use sine and cosine to convert from an angle to a position on the screen. If r is the radius, then the (x) and (y) coordinates are r * Math.sin(angle) and r * Math.cos(angle), where angle is measured in radians (so …

Member Avatar for neilcoffey
0
132
Member Avatar for neutralfox

As people have mentioned, you need to use asymmetric encryption at the very start of the conversation to send the sessiion key to the server. Use RSA for this. Essentially, you create a public/private RSA key pair as follows: [code] KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(2048); KeyPair kp = kpg.genKeyPair(); KeyFactory …

Member Avatar for neilcoffey
0
641
Member Avatar for caps_lock

I can't see a problem with writing this in Java. For the checksums, you could look at the MessageDigest class, or just use some other fairly strong hash function. MD5 isn't necessarily the best choice: it's designed to be a [I]secure[/I] hash function, and trades performance for that security. IMO, …

Member Avatar for jbennet
0
255
Member Avatar for srs_grp

You have a couple of options: - Use the [URL="http://www.javamex.com/tutorials/io/bytebuffer.shtml"]ByteBuffer[/URL] class (link is to a tutorial I wrote in case helpful), for example: [code] ByteBuffer bb = ByteBuffer.allocate(4); bb.put((byte) ...); bb.put((byte) ...); bb.put((byte) ...); bb.put((byte) ...); int intVal = bb.getInt(0); [/code] - More efficiently, just manually code it with shifts …

Member Avatar for verruckt24
0
846
Member Avatar for anujtripathi

For more effective programming, [B]don't[/B] try and memorise this list; bracket expressions appropriately so that any programmer can read them whether or not they have also memorised this list (practically nobody has). OK, it's probably safe to assume that most programmers know that * and / have priority over + …

Member Avatar for Ezzaral
0
139
Member Avatar for srs_grp

You don't actually have to go to all that trouble, though... [code] int val = Integer.parseInt(str, 2); float f = Float.intBitsToFloat(val); [/code]

Member Avatar for srs_grp
0
185
Member Avatar for bobi1234

For the [I]general[/I] case, essentially, you break the exponent down into a series of "multiply by x" and "square then multiply by x" operations. If you imagine the exponent in binary (without trailing zeroes), then for each bit position that there is (ignoring the highest bit), you need to square …

Member Avatar for bobi1234
0
104
Member Avatar for srs_grp

I think I'm missing something here -- as I did when you asked a very similar thing in another thread. If you just want to extract the substring between two character positions, then use the substring() method. So if str is "mnp1011000jie", then do: [code] String str1 = str.substring(0, 3); …

Member Avatar for verruckt24
0
172
Member Avatar for srs_grp

Not sure if this is what you mean, but once you have the binary number part "0101010" etc as a string (i.e. you've stripped off the other parts of the string), to convert to an int or long, look at Integer.parseInt() and Long.parseLong() -- pass in "2" as the "radix" …

Member Avatar for BestJewSinceJC
0
217
Member Avatar for Boyet728

Erm... I wonder if the solution your instructor wanted you to get at was to just make the loop go up to 5?

Member Avatar for ~s.o.s~
0
129
Member Avatar for av11453

Create a class to represent your "seg folder", then give it two String fields: name and description.

Member Avatar for neilcoffey
0
58
Member Avatar for jrobw

As the previous poster says, I think the whole point of your assignment is to demonstrate that a self-made LCG with bad parameters [I]doesn't[/I] work very well. As well as the abovementioned link, you may be interested in this article on my web site about the [URL="http://www.javamex.com/tutorials/random_numbers/java_util_random_algorithm.shtml"]java.lang.Random algorithm and LCG …

Member Avatar for neilcoffey
0
190
Member Avatar for srs_grp

Look at the ByteBuffer class. You can wrap a ByteBuffer around some bytes that you need to decode, then set the byte order on the buffer to either little/big endian (or the machine's native type), then pull out ints etc. Similarly, to ENCODE a value in little/big endian, allocate a …

Member Avatar for AlbertPi
0
228
Member Avatar for bachma7

Erm.. of course that last example is TCP, not UDP... @bachma7 -- if you're going to cross-post to multiple forums, please have the courtesy to tell people that that's what you're doing. In your [URL="http://www.java-forums.org/networking/14158-multi-clients-connect-udp-server.html"]previous post[/URL], I gave you some pointers and you mentioned you were getting an error and …

Member Avatar for neilcoffey
0
223
Member Avatar for sciwizeh

Difficult to wade through this code, but general recommendations to start finding the problems: - if you're subclassing things like Ellipse2D, don't spuriously have extra variables like 'x', 'y' that duplicate functionality of the underlying class -- you'll just tie yourself in knots keeping them up to date. When you …

Member Avatar for sciwizeh
0
135
Member Avatar for tristan17

As the previous poster mentioned, the easiest way to do this is to get your image into a BufferedImage somehow or other, then call getRGB() on the pixel you want. If your image is in a file, then you can usually call ImageIO.read() to load that image into a BufferedImage. …

Member Avatar for sciwizeh
0
702
Member Avatar for relequestual

I don't think the fact that the machine is quad core should really make any difference -- all of your stuff is executing in one thread (the GUI thread) anyway. What may make more of a difference is how fasd a SINGLE core can run compared to your other machine. …

Member Avatar for Ezzaral
0
1K
Member Avatar for CoolGamer48

Erm... silly question, but are you sure the file exists...? if you test (new File(filename)).exists(), what does it print?

Member Avatar for Ezzaral
0
177
Member Avatar for pocku

On average, you really wouldn't expect to perform so many recursions as to get a stack overflow error: even with your list size of 16,000, on average, you'd expect to go to around 14 or so levels of recursion (2^14 = 16384). But in the WORST case, quicksort will require …

Member Avatar for neilcoffey
0
192
Member Avatar for PhiberOptik

By the way, you should be very wary of just making your program call Runtime.exec() and "sitting back and relaxing": if the other process logs anything out (to either the standard output or error stream), you [B]must read the contents of those streams[/B] else things will generally freeze. If you …

Member Avatar for neilcoffey
0
85
Member Avatar for Sereal_Killer

I think the way you're storing things is a little bit odd, and that's tying you in knots. You've declared variables that duplicate one another: on the one hand, you've got the separate 'day', 'month', 'year' variables. And on the other hand, you've got the Calendar. Start by deciding on …

Member Avatar for neilcoffey
0
111
Member Avatar for robertmacedonia

An important thing to understand is that there are [B]two types of exceptions[/B]: [LIST] [*][B]checked exceptions[/B], which are thrown when your code (or some code in the Java libraries) explicitly throws them; in this case, methods that throw such exceptions must be declared as throwing them, and code that calls …

Member Avatar for Tyster
0
143
Member Avatar for clueless101

String.split() really can help you out, I think. If I understand rightly, the thing you're dissatisfied with is that the suggestion strips off the terminating punctuation from the strings. The expression's a bit more involved, but you can do something such as the following: [code] String[] sentences = str.split("(?<=[\\.!?]+)(?![\\.!?]+) *"); …

Member Avatar for ~s.o.s~
0
125
Member Avatar for it2051229

You should never call sleep() in the UI thread (in other words, directly in response to a button click or some other UI handler). To make the variable visible from another thread, you need to declare it somewhere where it is visible! Possibilities include having a subclass of Thread that …

Member Avatar for Ezzaral
0
92