When working with Sockets in Java, how can you tell whether the client has finished sending all (binary) data, before you could start processing them. Consider for example:
istream = new BufferedInputStream (socket.getInputStream());
ostream = new BufferedOutputStream(socket.getOutputStream());
byte[] buffer = new byte[BUFFER_SIZE];
i...
Ok, so I'm pretty noob at JAVA, and programming in general really. I'm trying to make a rock, paper, scissors app that with run with a GUI interface. What I'm trying is the simplest thing I thought of, press a button for your choice (r, p, or s) and that will make a variable used in the rest of the program to compare to the computer's ...
I've never used distributed caches/DHTs like memcached, jboss cache, ehcache, etc. I'm wondering which, if any, is appropriate for my use.
First, I'm not doing web applications (as most of these project seem to be geared towards web apps). I write servers (Order Management Systems actually) for financial trading firms. The servers th...
I have a variable of double type and the value in it is something like 34.323423423123456
I'd like to format it using String.format method (or whatever works) to have only 2 decimal places (e.g. 34.32), but to also round it properly, e.g. 2.229934345 will be 2.23.
I am new to Java and none the C# tricks worked. Thanks
...
I am writing a mad libs program for fun and to just program something. The program itself is pretty straight forward, but I find myself resorting to several concatenations due to the nature of the game where you place user given words into a sentence. Is there an elegant work around to resort to less concatenations or even eliminate them...
I've recently hit a wall with an issue with Java's native XML API (the W3C one) which at its core is that if I try to use a direct XPath expression in my document like, say, //body the XPath is evaluated as false (incorrect behaviour), however if I replace that with //*[1] it evaluates as true (desired behaviour).
I have checked numero...
I want to separate some DLLs from the associated native JNI classes.
Plugins:
In plugin A the dlls are placed and
loaded when the plugin is loaded.
In
plugin B (depend on A) the JNI
classes are placed which include the
native method calls for the DLLs in A.
At runtime i get a UnsatisfiedLinkError because the JNI class can't be foun...
I am processing time critical messages which are routed to me via a very slow network connection. I am connecting to the originating server (which I have no control over) with a Java TCP/IP Socket. The data is of varying length but is usually around 5000bytes and so ends up getting broken into multiple packets of roughly 1400 bytes.
...
how would one implement a back-button as a commandbutton that works universally? with back button i don't mean the browser-button, but rather a button that sits somewhere on the page. it is not always possible to use the Post-redirect-get pattern.
its quite impractial to pass around the information on every single where the button shoul...
I have 2 classes for the game i am making,
gui class and the logic class, for a game of noughts and crosses. The GUI class has a method that uses an array of JButtons and returns them all with the same anonymous inner class action listener
The problem is this, when i click the button i want the text to change to an x or a o dependant ...
I found this nice recipe and want to use it to deploy some 3rd-party files in our repository
The call on the command line is
mvn -P deploy-libs
If I do this for one file it works exactly as intended
<profiles>
<profile>
<id>deploy-libs</id>
<build>
<defaultGoal>deploy:deploy-file</defaultGoal>
...
Hi,
I would like to know, where does java stderr standardly go?
I know I can change the stderr using System.setErr, which 'Reassigns the "standard" error output stream.', but I dont know, which one is "standard".
I would like to specify my question more:
I have C++ library that I use in java (jni). The problem is that it appears that ...
I am currently using Emma as the code coverage tool for my project. I know how to get the code coverage analysis of running a sample Java test case. This will give me the code coverage details of the Java test case code, but, what I want to know is how much JDK code was covered in running the sample Java test case.
For example, if my t...
i am new to J2ME. please suggest me how can i install it and where from.
and what else i have to downlaod to install J2me ofcourse with jdk.
...
How do I do unix2dos (or dos2unix) with ant.
I.e. I want to change the newlines from linux newlines (if any) to dos newlines
...
if i have a class gui and a class for the logic, is holding a reference in gui to logic and logic to gui very bad?
...
My issue is more semantic than functional, As the code does seem to implement the deQueue and enQueue functions correctly.
The reheapDown and reheapUp functions are being used incorrectly, And i believe the issue lies in my heap function
package priqueue;
public class Hosheap{
private Patient[] elements;
private int numElements;
...
If i have a method in my gui that returns a list of JButtons then in my makeFrame() method i populate my GridView with these buttons, how can i get hold of these buttons in my logic class,
the logic i am using is to check the labels of the buttons, if three in a row with the same label then win else carry on. But the logic class cant ha...
I am extending the tools menu with my own action cmds using the below line in the plugin.xml
...
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=edit">
<menu
id="geditorToolsMenu"
label="T&ools"
...
What is your favourite Hibernate trick?
...