I need to store in a constant class 4 letter of a code. I can do:
static final String CODE_LETTERS = "TRWAG";
or
static final char[] CODE_LETTERS = {'T', 'R', 'W', 'A', 'G'};
After, I can obtain one of that characters in two ways:
final char codeLetter = CODE_LETTERS.charAt(index);
or
final char codeLetter = CODE_LETTERS[index]...
Whenever I open a socket channel. If the client accepts then 1 file descriptor is created internally so I can create a maximum of 1024 clients in Linux.
But I want to create more clients without increasing file descriptor limit in Linux
(ulimit -n 20000)
So how can I create more sockets in Java?
...
I have a rule LHS like that
when
$location : Location()
$cabinets : ArrayList() from collect ( Cabinet() from $location.elements() )
then
an when I print the content of @cabinets in RHS I see that it contains all elements (also those that are not of class Cabinet ).
I want to collect ontly cabinets from $location>elements()...
Hi,
I want to read a secure webpage data say https://www.paypal.com, i am behind proxy. I tried with
System.setProperty("java.net.useSystemProxies","true");
System.setProperty("htttps.proxyHost","myproxyhost");
System.setProperty("https.proxyPort","443");
URL u = new URL("https://www.paypal.com");
URLConnection uc = u.openConnection(...
I was wondering if anyone knew of a good way to format files sizes in Java/JSP/JSTL pages.
Is there a util class that with do this?
I've searched commons but found nothing. Any custom tags?
Does a library already exist for this?
Ideally I'd like it to behave like the -h switch on Unix's ls command
34 -> 34
795 -> 795
2646 -> 2.6K
2...
I have a parameterized hibernate dao that performs basic crud operations, and when parameterized is used as a delegate to fulfil basic crud operations for a given dao.
public class HibernateDao <T, ID extends Serializable> implements GenericDao<T, ID>
I want to be able to derive Class from T at runtime to create criteria queries in Hi...
Hi All,
I am a newbie to Java Web Application development. So far all I have used are plain old servlets, jdbc and jsps. I started to read about all the frameworks and I am totally confused and lost in the swarm of frameworks? So here are some questions I have:
Are EJB3 and Hibernate competing technologies or can they be used together...
After reading "Java concurrent in practice" and "OSGI in practice" I found a specific subject very interesting; Safe Publication. The following is from JCIP:
"To publish an object safely, both the reference to the object and the object's state must be made visible to other threads at the same time. A properly constructed object can be s...
Is there a way to read cobol data in a Java program? More concretely I'm confronted with the following case:
I have a file with fixed length records of data. The data definition is done as Cobol copybooks. What I think of is a library which taking into account the copybooks would be able to read those records.
Ideally it should be pos...
Hi,
I'm looking for a way to identify faces (not specific people, just where the faces are) and track them as they move across a room.
We're trying to measure walking speed for people, and I assumed this would be the easiest way of identifying a person as a person. We'll have a reasonably fast camera for the project, so I can probably...
Apparently Excel 4.0 is still used and I have to read it in Java.
Neither poi nor jExcelAPI, as great as they are, can parse them. I can't find anything on them, especially with Java. Any help? Thank you.
...
I've got a class somewhat like this:
public class Test {
private final List<ISomeType> things = new LinkedList<ISomeType>();
public <T extends ISomeType> Test(Class<T> clazz, int order) {
for (int i = 0; i < order; i++) {
try {
this.things.add(clazz.newInstance());
} catch (Excep...
Hi all,
I am interested in exploring the idea that the relationship between methods and the member varialbes they use can give a hint to how the class could be broken up into smaller pieces. The idea is that a group of variables will be closely related to one responsibility and should be contained in one class according to SRP.
For a t...
It looks like SpringSource has just released a GA version of their tc Server application server.
It sounds from their description like it is a drop-in replacement for Apache Tomcat, with better "enterprise capabilities", such as "advanced diagnostics", better operations management, deployment, etc. (and of course, the support that they ...
Hi all,
I have a situation where I am working with EJB3 and a legacy database. I have a situation where there is a many-to-many relationship between two tables A and B, defined through a third (link) table L.
The complication is that the link table has other fields in it other than the PK's of tables A and B. The columns are standard t...
I couldn't find documentation on an equivalent of Java's final in Python, is there such a thing?
I'm creating a snapshot of an object (used for restoration if anything fails); once this backup variable is assigned, it should not be modified -- a final-like feature in Python would be nice for this.
...
We recently pushed a web application (tomcat 5.5.x web app) into production and it started exhibiting odd behavior today. We don't see this behavior in any development or pre-production environment.
Our only view into the production system at runtime is logging. Although they can tell us what happened they can't really help us diagnose ...
In Mysql there is a compare operator that is a null safe: <=>. I use this in my Java program when creating prepared statements like this:
String routerAddress = getSomeValue();
String sql = "SELECT * FROM ROUTERS WHERE ROUTER_ADDRESS <=> ? ";
PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, routerAddress);
...
Is it possible to make the default Eclipse "Generate hashCode() and equals()" use getters instead of field references? - ie. can I get at the template that it uses?
I'm using Hibernate, and Proxied Objects are only LazyLoaded when getters are used and not from field references. It's an annoyance to be constantly changing it.
The obviou...
I have a thread that is supposed to listen for acknowledgements of messages and process them, but it seems that the thread is never reciving the acknowledgements.
Here is the relevant code in the thread:
private class TcpReader extends Thread {
BufferedReader reader;
boolean running = false;
public TcpReader(BufferedReader...