java

Using a java method to return multiple values?

I was just wondering whether or not there is a way to make a java method return multiple values. I am creating an application that uses the jdbc library to work with a database. Now, i can successfully enter values into the database but now i just need a way to return them and this is where im a bit stuck. I creating a form where the us...

java regular expression , how to add '[' to expression

Hi I want to creat a regular expression for strings which uses special characters '[' and ']'. Value is "[action]". Expression I am using is "[\\[[\\x00-\\x7F]+\\]]". I tried doing it by adding "\\"before '[' and ']'. But it doesn't work. Can any one help me with this. thanks -devSunday ...

What is meant by "implement a wrapper method"?

I have been given a programming assignment and one of the things I have to do is implement method which a wrapper method which relies on another method to sort the coordinates from lowest to highest. I am unsure on what exactly is meant by implementing a wrapper method. static void sortCoordsByZ(double[][] coords) { //implement the wra...

What is an appropriate way to programmatically exit an application?

I am evaluating user inputs as commands for my application. If the user presses Q, or q, and then hits enter, the application quits and execution terminates. Is there a proper context, or best practices on how to do that? I do not have any resources to release, or anything like that. Should I just use System.exit(0);? Is there a recomm...

unable to return to main() from a method reading standard input stream

I am basically trying to return from a method which reads user input from the standard input stream. Since the user has the option to quit the application, I am trying to figure out the best way to do this exit. Ideally I will be able to return from begin() and let main() finish, thus quiting the applicaiton. public static void main(Str...

Java - ByteBuffer.remaining() problems..

Summary: I have a ByteBuffer in which I am pumping some data. After that, I want to send this data over a Socket. So, I wrote code like this: private static void serialize(ByteBuffer buffer, EmployeeData emp, CharsetEncoder encoder) { // id buffer.putInt(emp.getId()); CharBuffer nameBuffer = CharBuffer.wrap(emp.getFirstName().t...

How do I trigger a servlet method on page load

I have entries in a text file which I want to load into a drop down box. I want this to happen on loading a jsp page. I could easily do this if I had a button that triggered the passing of a request object to the servlet. How do I send a request object on page load - do I need to use Javascript or is this something I can do with just jp...

Boolean Expression Evaluation in Java

Hey everyone, Is there a relatively simpler (when compared with writing a parser) way to evaluate boolean expressions in Java? I do not want to use the JEP library. I have a String expression something like: (x > 4 || x < 8 && p > 6) [ I will replace the variables with values. Is there a way by which I can evaluate this expression? The ...

eclipse magic: ... are only available if source level is 1.5, yesterday everything was working just fine

so yesterday i made a project in eclipse, and it was working, compiling, i used Eclipse Galileo for jee; now today i open eclipse and see lots of errors saying that stuff is not available and that it is only available if source level is 1.5 ...

How do I find the current focussed InternalFrame?

I am having multiple InternalFrames (JIF) added to a desktop manager. How do I know which one has the focus at the moment? ...

What should I use for implementing list feature in GWT.

Hello, I want to implement list like "stackoverflow question list" (where each row has multiple items, text, tags, user, time etc) in GWT. What should be most appropriate approach? I tried using FlowPanel and inside that "HTML elements" so result will be DIVs inside DIV. But, then CSS is pain.. (unable to set right aligned multiple rows...

Radix Sort Java

Welcome. I have a radix sorting method that uses an array to go through, but has to have another array (bin) that will store in an empty queue. I am confused as to how I would make a queue for the bins. I also have a findPlace method that finds the place of the each digit when called upon. So, here is what I got. Can someone help me find...

Maintaining a single instance of JInternalFrame?

Hi Everyone, I have an application which opens multiple JIFs, But I only want to create a single instance of the JIF, so I use these function to check that, and I use dispose to close the JIF after a key is pressed(JDesktopPane.getSelectedFrame().dispose()). However after 2-3 successive disposes, it doesn't create a new JIF? Am I doing ...

How to stop repeated keyPressed() / keyReleased() events in Swing

So the problem that I am having appears to be a bug that occurs only on Linux. I'm trying to have my swing app record when a key is pressed down, then to detect when that key is released. Now that shouldn't be in issue because KeyListener is supposed to handle this for me. The problem is that when I hold the key down I get lots of repea...

javadoc: show also descriptions of methods from parent class

Is there a way to produce javadoc so that all methods accessible from the class are listed with their full description? Usually only the methods defined in that class are listed and the rest are only linked to in "methods inherited from" section. (Obviously it is tricky to show javadoc of super classes if they're thirdparty and there's...

Eclipse - Mac Os Default JRE missing

The list of installed JRE's is empty, when I click "add" the only options I'm given are - Execution Environment Description, Standard 1.1.x VM, Standard VM. There's no option for a MacOS Default JRE and choosing standard VM results in the usual "Standard VM not supported on MacOS". Eclipse Galileo, Mac OS X 10.5.8. Any suggestions muc...

Regex to extract link content

Hi All, I'll be the first to admit that my Regex knowledge is hopeless. I am using java with the following Matcher m = Pattern.compile(">[^<>]*</a>").matcher(html); while (m.find()) { resp.getWriter().println(html.substring(m.start(), m.end())); } I get the following list: >Link Text a</a> >Link Text b</a> What am I missing to re...

Pseudo code needed if possible?

Hi, I was wondering if I could have some pseudo code for working out the following i need to loop through a 2d array(the method i am working on takes an int). It starts at the position of the value passed in and then goes down until it hits the same value on the left hand side. As its doing this every int in the 2d array is added to a l...

Is there any benchmark which compares PHP and JSP?

I don't want to make a holy war. I just want to know if there is such benchmark? Or maybe you can say something about this thread from your experience? ...

Java newbie question: static{}?

Can someone explain me what the following is? public class Stuff { static { try { Class.forName("com.mysql.jdbc.Driver"); } catch ( ClassNotFoundException exception ) { log.error( "ClassNotFoundException " + exception.getMessage( ) ); } ... } What does th...