java

Improve BufferedReader Speed

I am crunching through many gigabytes of text data and I was wondering if there is a way to improve performance. For example when going through 10 gigabytes of data and not processing it at all, just iterating line by line, it takes about 3 minutes. Basically I have a dataIterator wrapper that contains a BufferedReader. I continuously...

how to sort Map values by key in Java

I have a Map in java that has strings for both . Data is like following <"question1", "1">, <"question9", "1">, <"question2", "4">, <"question5", "2"> I want to sort the map based on its Key's. So In the end I will have question1, question2, question3....an so on. Eventually I am trying to get two strings out of this Map. First Str...

Differentiating Programming languages: Java and C#

Possible Duplicate: Is it worth learning Java when you already know C# fairly well? I have been working on the .net framework for the past 5 years. Does it make sense to learn Java. Aren't both the Java and C# language / runtime / libraries meant for general purpose programming? How do they differentiate themselves? I guess w...

Secure Debugging for Production JVMs

We have some applications that sometimes get into a bad state, but only in production (of course!). While taking a heap dump can help to gather state information, it's often easier to use a remote debugger. Setting this up is easy -- one need only add this to his command line: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,a...

split() method fail

I'm reading a text file with the following format: Room1*Exposition*Work 1 | Work 2 | Work 3 | Work n Room2*Exposition*Obra 1 | Work 2 | Work 3 | Work n Using the following: try { String path="contenidoDelMuseo.txt"; File myFile = new File (path); FileReader fileReader = new FileReader(myFile); ...

Java network server and TIME_WAIT

I have run into a problem with a network server that receives signals from devices my company produces. The device will occasionally reuse the source port that it had just used. This causes the SYN to be dropped by the server. The device then retries until the old socket falls out of TIME_WAIT on the server. The server then SYN-ACKs....

exception when invoking ehcache-server within embedded Jetty via Cargo: WebApplicationProviderImpl could not be instantiated

I'm working on a web application that uses a standalone ehcache server to cache certain data. The ehcache server is accessed via REST (as opposed to SOAP). For functional testing purposes, I need to run an embedded instance of the ehcache server. The echcache-server project itself does this for its own functional tests, using the Cargo ...

Eclipse performance on my G4 is horrific - any thoughts on a replacement?

I have a 5yr old G4 PowerBook that I use while travelling, and I had intended to get some work done whilst I am away for the next few weeks. Eclipse just seems to be horrendously slow on it. I've tried tweaking the memory allocated to the VM, but it doesn't seem to do very much :) Any thoughts as to why it's so slow? I don't get this p...

How to track task execution statistics using an ExecutorService?

I'm firing off tasks using an ExecutorService, dispatching tasks that need to be grouped by task-specific criteria: Task[type=a] Task[type=b] Task[type=a] ... Periodically I want to output the average length of time that each task took (grouped by type) along with statistical information such as mean/median and standard deviation. Th...

Overhead with Microsoft JDBC driver when executing a stored procedure

I am using Microsoft JDBC Driver 2.0 with SQL Server 2005. To explain my question better, let me start with a sample code to call a stored procedure. public static void executeSproc(Connection con) { CallableStatement cstmt = con.prepareCall("{call dbo.getEmployeeManagers(?)}"); cstmt.setInt(1, 50); ResultSet rs = cstmt.executeQ...

Does Google use Python for anything but internal utilities and administration?

I'm curious...I've read much of Python being on the approved list of languages used by Google employees, and I know they employ Guido. That said, is their use of Python focused mainly on managing servers and applications, and not for developing the applications themselves? If so, why? It seems most I read indicates they use Java for the ...

JAX-RS is perfect for implementing REST. What do you use to call REST services in Java?

Ideally, I am looking for something like JAX-RS (using annotations to describe the services I want to call), but allowing to call REST services implemented using other technologies (not JAX-RS). Any suggestion? ...

java type erasure vs. Field#getGenericType and Method#getGenericReturnType

As I understand them, generics are a compile time feature of Java, and parametrized type information does not exist in the compiled byte code. I have now discovered the Field#getGenericType and Method#getGenericReturnType methods, thusly shattering my world view. Please help me to piece it together. ...

Eclipse 3.2 or 3.4?

Is there really a big difference between Eclipse 3.2 and 3.4? I am currently using 3.2. ...

How to handle long file names in javax.mail

I am new to using javax.mail API, version jdk 1.6.0.11. I am using javax.mail API to parse a MIMEMessage text and extract the attachments. If the MIME message contains attchments that have very long file names javax.mail API is not able to parse it and reports no attachments. I would appreciate any help on this. Thanks! ...

The Math of a Jump in a 2D game.

I have been all around with this question and I can't find the correct answer! So, behold, the description of my question: I'm working in J2ME, I have my gameloop that do the following: public void run() { Graphics g = this.getGraphics(); while (running) { long diff = System.currentTimeMillis() - lastLoop; ...

Converting A String To Hexadecimal In Java

I am trying to convert a string like "testing123" into hexadecimal form in java. I am currently using BlueJ. And to convert it back, is it the same thing except backward? ...

What component do I need to get this Calendar?

I'm trying to get the Calendar from here running. I've no experience working with GlassFish or the JavaServer Faces components, and so I'm lost when I read the tutorial saying that the Calendar should appear on my Palette? Is it my Netbeans Palette or is elsewhere? I downloaded GlassFish and ran the .jar but I don't see any changes on m...

How to get data from Set in one go

I want to get all values of a set interface in one go as a comma separated string. For Example(Java Language): Set<String> fruits= new HashSet<String>(); fruits.add("Apple"); fruits.add("Banana"); fruits.add("Orange"); If I print the set as fruits.toString then the output would be: [Apple, Banana, Orange] But my requirement is A...

Java : how do you convert nanoseconds to seconds using the TimeUnit class?

how do i convert this value from nano seconds to seconds? I have the following code segment: import java.io.*; import java.util.concurrent.*; .. class stamper { public static void main (String[] args ){ long start = System.nanoTime(); //some try with nested loops long end = System.nanoTime(); long elapsedTime = end - start; ...