java

Can anyone suggest a good open source HTML parser to be used with java?

Hi I would like to know a good HTML parser for both static and dynamic HTML in java. It needs to be light weight as it is to be used on a mobile application . Is there anything already present? ...

JButtons need to modify 8 JTextFields using an Array. Listen to Buttons or Text?

This is homework. Beginning Java class. Still wrapping my head around this stuff. This questions Extends this one So there is a button for First, Prev, Next, and Last Each should modify Item ID, Name, Rating, Price, Units, Value, Fee, ValueW/Fee, Total Inventory Value The last one is a static total of all units) I am not sure if ...

Comparing Values in a file with an array

I have a .txt file with integers on each line e.g. 1 4 5 6 I want to count the occurences of the values that are in an array with the file. My code extract is this String s = null; FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); while ((s = br.readLine()) !=null) { StringTokeni...

How do I translate this SHA function in Java to an equivalent in Ruby?

I have this algorithm in Java to store passwords in database. I'd like to re-write my application in Ruby on Rails, so I need the same algorithm to compare hashed passwords. What's the Ruby equivalent of this algorithm? public static String encrypt(String password) { MessageDigest md; try { md = MessageDigest.getInstance("SHA"); m...

Java: Regex on byte array

I want to do something like a regular expression in Java, but on a byte array instead of a String For example, let's say I want to delete from the array all continuous segments of 0's longer than 3 bytes byte a[] = {1,2,3,0,1,2,3,0,0,0,0,4}; byte r[] = magic(a); System.out.println(r); result {1,2,3,0,1,2,3,4} Is there something th...

Formatting (for money) with setText(String.valueOf)

In my code there are some calls to a method that set the values of some JTextFields fields[7].setText(String.valueOf(inv.get(currentDisplay).feeValue())); This works and it is doing what I want but the values look like this 81.65849999999999 How would I make the output of String.valueOf look like the normal output of System.out.pri...

Dynamicaly extensible generic parser

I wrote an application which makes use of a meta-parser generated using CSharpCC (a port of JavaCC). Everything works fine and very good I can say. For the nature of the project, I would like to have more flexibility on the possibility to extend the syntax of the meta-language used by the application. Do you know any existing libraries ...

Can a Parent call Child Class methods?

Referring here A is a precompiled Java class (I also have the source file) B is a Java class that I am authoring B extends A. How can logic be implemented such that A can call the methods that B has. The following are the conditions: I don't want to touch A(only as a last option though that is if no other solution exists). I don'...

why use jsp:useBean here but not just create a new object ??

In a JSP page, there is such code: <jsp:useBean id="checklog" class="com.google.admin.guard.CheckLogBean" scope="session" /> and then <% checklog.checkit(); %> Why we don't just create the object with new com.google.admin.guard.CheckLogBean? What's the benefit of doing this? And in the source code, there is no such class, but wh...

How to set a complex custom crontab in google-app-engine (java)?

I am building an app for which I need to set up cron jobs. What I want to do is to set the specific minutes in a hour where specific crons should run. For instance: Task1 at 1st minute of the hour Task2 on every second minute of the hour Task3 every 2 minute only in the second half of the hour Building this in the standard Unix cron ...

Should Intermediate Java Programmer Read Fundemantals Part Of Java Books?

I love reading programming books.But every Java book has first intro part to the language which has chapters about language fundemantals like variables,loops,decision making, etc.I am wondering if you reading these parts of the books or skipping to the parts that intrest you? ...

How to upload it to server?

Hi friends, i want to upload the sound file (.ogg) in server. But it should write into the server concurrently while recording. My program it gets the input as PCM_SIGNED audio encoding though its the raw format i have to encode and upload it to server As for now i employed vorbis encoder to convert the raw format to .ogg f...

How to draw visual graphs with circular nodes and lines as connections between them?

I want to draw a map some cities in a software that I am designing. I want to know the algorithm for placement of circular nodes on screen (so they dont overlap each other) Please explain in relation to JAVA GUI programming if possible ...

How to detect whether Printer is attached to your computer or not in Java ?

Hello, I am creating one GUI in swing Java. I have to use one button " Print " which will directly start printing the file I have set without opening the default Print dialog box. I have to check first whether printner is attached to my computer or not ? ...

Java Thread using static or non-static nested class

I've encountered a very strange problem. My program looks like this: class Outter{ class Inner extends Thread { public void run(){ // do something } } public void func() { new Inner().start(); // Thread.sleep() for a while to see if the above thread has fin...

How to convert Excel to XML?

I've a requirement something like this. I've to convert an Excel to XML Spreadsheet. After googling, I found jexcelApi. But it's not retaining the format. Any suggestions on How to convert an Excel to XML format, retaining the Excel formatting? Thanks :) ...

How to use an array constant in an annotation

I would like to use constants for annotation values. interface Client { @Retention(RUNTIME) @Target(METHOD) @interface SomeAnnotation { String[] values(); } interface Info { String A = "a"; String B = "b"; String[] AB = new String[] { A, B }; } @SomeAnnotation(values = { Info.A, Info.B }) vo...

How to check Printer is connected or not to your PC by Java ?

Hello, I am able to get the name of printer which I had installed previously on my PC.But now its not physically connected to my pc. How should I check it first before moving to Print() in Java. ...

How to Serialize a list in java?

I would like to deep clone a List. for that we are having a method SerializationUtils.clone ( object ) // apache commons method. Object shld be serializable so now to clone my List i should convert that to serializable first. Is it possible to convert a List into Serializable list? ...

What tech needed to run JSP and Servlets?

If I want to build a site with PHP, all I have to do is install the PHP package and make sure mod_php is enabled in my apache web server. Voila! a PHP environment. Now, if I want to build a site with equivalent Java tech, i.e. JSP and Servlets, What do I have to install? ...