I'm trying to fetch this page (it's in Chinese, sorry for that):
amazon(dot)cn/s?rh=n:663227051
using the following code:
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class Application {
public sta...
hi,
i'm creating a web page which contains a few dynamically generated images.
in my page request handling i create all of the images and store them in a memory cache until they are subsequently requested by the browser.
public class CachedImage
{
byte[] data;
Date created;
}
currently, my image cache is essentially a HashMa...
Is it possible to have a minimize and maximize button for a non-modal(modal=false) JDialog.I know JFrame is the ideal solution for this but this change has to be made in an existing code and its little difficult to change from JDialog to JFrame.
...
I have heard that Java must use a JIT to be fast. This makes perfect sense when comparing to interpretation, but why can't someone make an ahead-of-time compiler that generates fast Java code? I know about gcj, but I don't think its output is typically faster than Hotspot for example.
Are there things about the language that make this d...
I've read all about how double checked locking fixes never work and I don't like lazy initialization, but it would be nice to be able to fix legacy code and such a problem is too enticing not to try to solve.
Here is my example:
private int timesSafelyGotten = 0;
private Helper helper = null;
public getHelper()
{
if (timesS...
How are DAOs usually designed for the typical business application ? Does one class or pattern dialogue with the data source or do you simply have a separate DAO for each Entity ?
...
I want to build a "toJavaCode()" on my model that would generated the required Java source code to generate that model (never mind the reasons or if it should or shouldn't be done, nor the compatibility issues that may occur).
I'm at a loss at how to test this. I'm using maven, but generate-sources won't really work for me since my serv...
I've really a long sequence of characters such as 123222222222230000000000001. I want to convert this to a long. What is the most efficient way to do it in Java?
UPDATE: The max length of sequence is of 31 characters
...
I have been using Hibernate ORM, which is an implementation of the JPA specification to manage relational data. I have also heard of the JDO specification that supposed to do the same (manage relational data).
What are the fundamental differences between the two? Any code samples most appreciated. How does JDO integrate with other Java ...
Hi ,
I am using HQL to save an object in the DB. It is something like this
Query query = sessionFactory.getCurrentSession().createQuery(ASK_FOR_HELP_SAVE_QUERY);
query.setInteger("status", askForHelp.getStatus());
query.setString("requestId", askForHelp.getRequestId());
query.setString("toAccountId", askForHelp...
As we know , there are a lot of java decompiler tools which can convert .class to .java file.
Therefore,we need to protect our .java files against decompiler. I know this is a big topic,and maybe there is no ending.
Usually, there are two ways : obfuscator and customized classloader.
Is there any mature solution or open source framewo...
I have a JSplitPane which when shown should split the pane by 50%.
Now on giving an argument of 0.5 (as suggested) to setDividerLocation, Java seems to treat it as a normal number instead of a percentage. As in, the divider, instead of going to the middle of the pane, is almost at the start of the left pane (the pane is vertically split...
I am trying to have a circle appear on the screen, then when the user clicks INSIDE the circle, enable the ability for them to drag the circle where the mouse goes while it is being pressed.
This is the code i have so far, the drag works, but it is allowing the user to drag without them pressing the inside of the circle, just when anywh...
Is there any performance testing results available in comparing traditional for loop vs Iterator while traversing a ArrayList,HashMap and other collections?
Or simply why should I use Iterator over for loop or vice versa?
...
Hello: I am trying to deploy a war file outside of a deploy folder in jboss. I changed the context.xml with the following content:
<Context docBase="C:\Apps\foo.war" reloadable="true" privileged="true" antiResourceLocking="false" path="/"></Context>
The context file is inside jboss-5.1.0.GA\server\default\deploy\jbossweb.sar\ in 5.1.0...
The classic of writing a singleton in java is like this:
public class SingletonObject
{
private SingletonObject()
{
}
public static SingletonObject getSingletonObject()
{
if (ref == null)
// it's ok, we can call this constructor
ref = new SingletonObject();
return ref;
}
priv...
I have a Person class which contains information like:
personId;
firstName;
lastName;
birthDate;
identityCardNumber;
address (contained Address object);
... a lot more data about the person.
Whenever I need to perform operations on a person’s data, an object from this class provides all the info I need.
Now, I also have a page w...
I have these two classes in my database package:(DBManager and TaskManager class)
and I create a new object in my main frame which is in the other package and I also imported the database package for my main frame and I call addBirth() on my object,and I want to insert these arguments in my table="birthsql" in MySQL but I found this stac...
I want to sort a vector contains like [a,b,1,3,5,z] both ascending and descending on Java ME, i.e. without using function like Collections.sort()
...
Hi,
So we are running a web application that has been tested on Tomcat, Glassfish, WebLogic and WebSphere. All run correctly except WebSphere. The issue is that filters are not processed for files under a certain directory.
For example I have a filter that checks the user's lanuage from browser cookies and another that get the user's u...