I have a List and want to reduce it to a single value (functional programming term "fold", Ruby term inject), like
Arrays.asList("a", "b", "c") ... fold ... "a,b,c"
As I am infected with functional programming ideas (Scala), I am looking for an easier/shorter way to code it than
sb = new StringBuilder
for ... {
append ...
}
sb.toS...
I'm writing an installer that will tune the configuration of the product for the particular hardware on which it will be run. In particular, I want to determine how much physical RAM is installed in the system so I can estimate how much memory to allocate to the product when it runs.
Ideally, I'd like to do this in a platform-independe...
I'm formulating an Ajax request using prototype in the following method:
function updateServerStep(stepNumber){
alert("updating server step to " + stepNumber);
var params = {stepNumber:stepNumber};
alert(params.stepNumber);
var request = new Ajax.Request('UpdateStep', {
method:'Post',
parameters:params,
...
Hi,
I'm trying to create a J2ME app, which talks to webserver using HttpConnection connector.
When I am talking to the WebServer, I have to authenticate using Basic HTTP auth, which normally goes like
http://username:[email protected]/rest/api/method
But in J2ME, when I construct a url of this form, it doesn't work.
I also tried...
I have several Java projects checked out into my Eclipse workspace, some of which are being worked on by several distributed teams. Is there a plug-in/setting that will allow me to detect exception blocks that are empty? I am trying to figure out how we can improve code quality across all of our projects and avoid expensive defects down ...
The example from FormPanel's javadoc says:
"...Assuming the service returned a response of type text/html, we can get the result text here (see the FormPanel documentation for further explanation)..."
However the javadoc doesn't explain a bit about this topic. Has anyone found how to get the HTML response sent back from server after a ...
The setting is a typical MVC J2EE application, with DAOs for data access.
There are a number of type entities, for instance for a Product bean there is a ProductType member bean, both persisted.
When I am persisting a Product bean, I want to populate it with ProductType info. I have the status code, but do I have to go to the database ...
I'm trying to iron out some UI rendering bugs in my java applet in OS X, and I've hit one that I can't figure out.
All the windows that we open that extend java.awt.Frame seem to ignore the setBackground() calls, and instead use the OS X default (brushed metal or gray gradient, depending on the OS version). Anything we open that extend...
Hello everybody
Here is my data model (simplified)
public class AddressBook {
private List<Group> groups = new ArrayList<Group>();
private List<People> peoples = new ArrayList<People>();
@OneToMany(mappedBy = "addressbook", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OnDelete(action = OnDeleteAction.CASCADE)
@Cascade(org....
If i make java core dump with gcore then what is the best tool to analyze it? I need to be able make jmap, jstack, jstat etc and also i need to see values of all variables.
Something that can take core dump as frozen JVM.
...
Every time we update our Java application (Java client and Java server) we have the problems that some clients approx. 1% - 2% does not load the new jar files. This occur with applets and also with Java Web Start. If you clear the Java Cache then all is working correct.
Any idea why Java does not check for new jar files on every start?
...
I have some radio buttons whose text may be very long. Is there an easy way to word-wrap them?
Yes, wrapping them in <html> tags and inserting <br> tags would work, but is there a more automatic way to accomplish this? I don't really want to roll my own typesetter.
...
I'm trying to map an @Embeddable object in a subclass whose parent class already has a field of that @Embeddable type.
The hibernate Embeddable Objects documentation claims I can use the @AttributeOverrides to override the column names of an @Embeddable object:
e.g.
@Entity
public class Person implements Serializable {
// Persist...
If I declare just the 2 varargs methods as follows:
public void foo(String... strings) {
System.out.println("Foo with Strings");
}
and
public void foo(int... ints) {
System.out.println("Foo with ints");
}
and then have the code:
foo();
this is a compiler error due to the ambiguity as expected.
However if I have just the...
We are trying to calculate a HMAC-SHA256 digest in Coldfusion and we are using the HMAC CFC, but in one case it is producing a different result for the digest compared to ones generated in different languages - have tried the same data using Ruby & PHP and get the expected result. I have also tried the CF_HMAC custom tag it is based on a...
I want to implement a chat site with following features:
Direct one-on-one chat with a randomly picked stranger
If my conversation partner gets disconnected, I should be shifted to different stranger
In short, I want to imitate http://omegle.com/
Which language is best suited to this task? Jsp and Java? PHP? ASP? Others?
Should a...
Is there a way to exclude code from inclusion into Cobertura coverage reports? We have some methods that should not be include in the coverage report and therefore not drive down the coverage numbers.
I know that Clover has such a functionality, but I have not found anything similar for Cobertura.
...
If I create a Customer and Controller, then associate my Controller with a customer it saves fine.
If I then remove my controller it doesn't remove the relationship between them.
This causes an EntityNotFoundException when I load the Customer.
javax.persistence.EntityNotFoundException: Unable to find Controller with id 22
I'd like to...
How to handle StackOverflowError in Java ?
...
Is there a best practice for where configuration files should be stored in a Java project. The file type is a Java properties file in this case, but I do use other file types in other projects.
Would the recommendation vary from stand alone application(.jar) to web app(.war)?
...