java

What is the deal with the unicode character 首(U+9996) and how java/mysql deal with it and its friends?

Man, this character encoding hole just keeps on getting deeper. Sigh. Ok. Check this out: I have a java String that contains the unicode character U+9996 (that's what I get if I do codePointAt()). If I look at it in the debugger expressions panel (in eclipse) then all is well and it looks like "首". However if I print it out to the conso...

Java: Run a Callable in a separate process

Given an instance x of Callable<T>, how can I run x in a separate process such that I can redirect the standard input and output of the process? For example, is there a way to build a Process from a Callable? Is there a standard Executor that gives control over input and output? [UPDATE] It's not important that the Callable execute in a...

Sorting domain names

Has anyone implemented sorting a list of domain names? I have seen some applications sort them as flat strings, but the problem is that you end up scattering all the related hosts in a domain: a.me.com a.you.com b.me.com b.you.com So, the basic logic I came up with reverse the order of the labels, then sort. FQDNs of one label should...

Using the Rome Java API to access metadata fields

I've been using the Rome API to parse data from an XML feed pretty successfully so for, but have run in to a bit of a snag. Given the following snippet of XML: <entry> <id>uniqueId</id> <updated>2008-11-05T01:32:35Z</updated> <mm:status xmlns:mm="http://contentprovider.com&amp;quot; available="true"/> <title>Title</title> ...

Java String Parameters

I'm coming from a .net background and want to know the accepted way of creating a method that returns a boolean and modifies a string that was passed in via parameter. I understand Strings are immutable in Java so the below snippet will always produce an empty string. I am constrained to return boolean only. Exceptions can't be thrown. I...

Java Timer class says "Timer tasks should complete quickly" , how do we define quickly?

I am planning to use this to poll a database which can take close to 10-15 minutes or more, so should I be using timers for this. ...

How can I capture the output of an Executable in an image?

I want to capture the output of an exe file as an png or jpg image, i mean the display of that exe. Is there any command on windows to capture and save as image of an exe output or any other idea that i can do this. ...

create java console inside the panel

How can I create an instance of the Java console inside of a panel? ...

How do I convert an audio stream to MP3 using Java?

Is it possible using Java to convert a real time audio stream from the mixer to MP3? It has to be converted chunk by chunk otherwise the memory will be exhausted. I already know how to record but only to lossless formats such as wav and aiff. I need conversion as the audio comes in. ...

Unable to parse XML file using DocumentBuilder

I have this code: if (file.exists()) { Document doc = builder.parse(file); NodeList list = doc.getElementsByTagName("property"); System.out.println("XML Elements: "); for (int ii = 0; ii < list.getLength(); ii++) { line 2 gives following exception E:\workspace\test\testDomain\src\com\test\ins\nxg\maps\Right.hbm.xml ...***jav...

What is this java.awt.event error?

ANSWER: If you ever see these lines and are mistified like I was, here's what they mean. Thread[AWT-EventQueue-0] (Suspended (exception NullPointerException)) EventDispatchTread.run() line: not available [local variables unavailable] It's not that the variables are unavailable because they are lurking behind a shroud of mystery in a ...

Java synchronisation poll

Here's some code I saw once. Can you see what's wrong with it? [updated] public class ResourceManager1 { private final String mutex = ""; Object resource = null; public Object getResource() { synchronized (mutex) { if (resource == null) { resource = new Object(); } } return...

Produce a simple Video - uncompressed, frame by frame

Hi, I need to an algorithm, to write frames (Pictures) into a file, which can be read by some Video-Cutting/Producing-Software to work with. So I got frames, and I want to give them a input into a function/Method. Let's do i in Java. How can I do this? Is there a simple way, I can write videofiles without using any systemcodecs? I jus...

How do I get whole and fractional parts from double in jsp/java?

How do I get whole and fractional parts from double in jsp/java ? If the value is 3.25 then I want to get fractional =.25, whole = 3 How can we do this in java? Any pointers is highly appreciated. ...

Struts 1.3: How to set a default Locale in a web app ?

I have two or three i18n files in my struts application. I am able to switch between these by setting the Global.LOCALE_KEY variable in the session. Is there a way to set a default locale for the application (probably in the struts-config.xml file, I guess) ? Is the session the only place to set the locale ? Sure, I could intercept the...

How to let JAXB render boolean as 0 and 1, not true and false

Hey guys. Got a quick question. Does anyone know how to let JAXB (marshall) render boolean fields as 1 and 0 instead of printing out "true" and "false"? ...

How to get all Enum values in XMLBeans?

Hello Apache XMLBeans can be used to generate Java classes and interfaces from XML Schema Definition files (XSD). It also generates Enums based on StringEnumAbstractBase and StringEnumAbstractBase.Table to represent domain values. They are handy for entering only valid values. However, I want to get all those values to generate a JCombo...

Is there source code analysis api in .net similar to those in java?

The APIs that might be of interest to developers of Java applications that need to perform source code analysis are the Java Compiler API (JSR 199), the Pluggable Annotation Processing API (JSR 269), and the Compiler Tree API. Any similar api or library for .net? ...

How do you create (and read) windows shortcut(.lnk file) in Java?

Same question, different langauge. How do you do it in Java? Do you use JNI? run exe? or are there any library read/write *.lnk like POI read/write *.xls? I used to workaround to create ".url" which is plain text INI file. But I am looking for other interesting way to do it. ...

Java performance with very large amounts of RAM

I'm exploring the possibility of running a Java app on a machine with very large amounts of RAM (anywhere from 300GB to 15TB, probably on an SGI Altix 4700 machine), and I'm curious as to how Java's GC is likely to perform in this scenario. I've heard that IBM's or JRockit's JVMs may be better suited to this than Sun's. Does anyone kno...