java

Java - Reading input from a file. java.io.FilterInputStream.available(Unknown Source)?

Hi. I haven't written any Java in years and I went back to refresh my memory with a simple 'read-from-file' example. Here is my code.. import java.io.*; public class filereading { public static void main(String[] args) { File file = new File("C:\\file.txt"); FileInputStream fs = null; BufferedInputStream b...

Utilising a file association in a Java application.

I am in the process of writing a cross platform Swing based application in which I want to utilize a file association which has been registered with the OS. So iv got to the point where I can click on a file and my app loads, but what I need to know is how I can get my application to know where the file is that launched it and then quer...

AndroMDA maven code generation and JPA Annotations

I am using the AndroMDA plugin for maven to generate code from an uml diagram made in MagicDraw. When the code is generated, AndroMDA desings the JPA annotation for the persitence layer. I think that at the compilation process AndroMDA uses Naming Strategies to determine the Table and Column names for the DataBase. I want to determine ...

How to remember last values in a Swing GUI form?

Hello. I have a simple Java GUI form made with Swing. It has some text inputs and checkboxes and I want it to remember the last values input to these. Of course it is possible to save them to some file manually and then read the file and fill the inputs, but I wonder if there's a way to do this more or less automatically. Thanks ...

How to restart a method from inside it in java

Hi, is there a way of restarting a method in java from inside the one you want rerun? thanks ...

Java - static factory method and switch statements

Hi guys, I am dealing with a set of message objects, each of which has a unique identifier corresponding to them. Each message can be constructed either from a Map, or from a ByteBuffer (the messages are binary, but we know how to transfer to and from a binary representation). The current implementation for constructing these messages...

Does SOLR use up alot of memory on a server?

I have NO EXPERIENCE with SOLR. Does SOLR use more memory than say MySql on a server? I am about to purchase a VPS-package, but they come in different sizes as you can imagine... I contacted the providers today by email, and told them that I was planning on using SOLR which requires java installed. Their response was that it would w...

What is the performance difference, if any, between if(!foo) and if(foo == false) in Java?

Logically, if(!foo) and if(foo == false) are equivalent. How are they represented in Java? Is there any difference between the two after compilation, either in the bytecode or in performance? I was unable to find an answer in the JLS, and searching brought up a lot of results about = vs. == typos and ==/equals() behavior. (In this ca...

In Java, how to get attribute given the string with its name?

Hi, I'm sorry for asking this sort of questions, but I really couldn't find the answer in Google. So say I have a class with private String myColor and I have a string "myColor". Now I want to manipulate the myColor attribute. How can I do that? Edit: Sorry for an unclear question, I guess the best way is to explain what I need it for....

jframe component layout

How can I specify the location on JFrame that a component (JLabel specifically) is placed? I created a JFrame object and added a JLabel and a JList to the frame but both objects are being placed on top of each other. I have tried using label.setBounds(10,10,10,10); list.setBounds(20,20,100,100); and label.setLocation(10,10); list...

In httpclient what is the most elegant/correct way to turn HttpEntity to a String?

I'm fetching a web page using the Apache httpcomponents Java library. After connecting the result I get is an HttpEntity which has a method getContent() which returns an InputStream and also has a method writeTo() which writes to an OutputStream. I want to turn the result into a String for extracting information. What is the most elegan...

scheduling tasks on JBoss with clustering

I need to be able to run some scheduled tasks (reports) for an EJB application running on JBoss 4.2. In my initial implementation I am using a servlet in an associated WAR to read some configuration from a properties file and then reset the scheduled tasks using the Timer Service API. This works but it seems a bit awkward to have the...

convert spreadsheet formulas to java

What tools are available to convert an OpenOffice or Excel spreadsheet (with all its formulas) into a Java object that can be called at run-time? Obviously this would only make a calculation engine and just be about numbers and text, not timing or API calls. Even with named cell ranges being used to (effectively) name variables the out...

Saving Android application state

I understand how to save an application's state by using SharedPreferences, onSavedInstanceState() & onRestoreInstanceState(), etc as outlined in a similar post ( http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state ), but how do I save the last activity? To be more specific, my application starts up and...

Replacing JWSDP jar files with up-to-date equivalents from Maven repo

I inherited an old project that uses JWSDP, and would like to upgrade it to Maven 2 and Java 6. The project uses the following JWSDP jar files: jwsdp-jax-qname-1.5.jar jwsdp-jaxrpc-api-1.5.jar jwsdp-jaxrpc-impl-1.5-patched-1.10.jar jwsdp-jaxrpc-spi-1.5.jar jwsdp-namespace-1.5.jar jwsdp-relaxngDatatype-1.5.jar jwsdp-saaj-api-1.5.jar jw...

netbeans & java, resourceMap.getString returning null

Product Version: NetBeans IDE 6.8 (Build 200912041610) Java: 1.6.0_17; Java HotSpot(TM) Client VM 14.3-b01 System: Windows 7 version 6.1 running on x86; Cp1252; en_GB (nb) Hello, newbee java programmer here and wondering if someone can help, I have been having some problems updating a GUI for a desktop application in netbeans, here are ...

Audio Stream Transcoding with Android

Let me first state that I do not know Java. I'm a .NET developer with solid C# skills, but I'm actually attempting to learn Java and the Android SDK at the same time (I know it's probably not ideal, but oh well, I'm adventurous :)) That said, my end goal is to write a streaming media player for Android that can accept Windows Media str...

How to show collection elements as items in selectManyListbox?

I have a bean: public ProjectServiceImpl { public List<Project> getAllProjects () { ... } } I want to list all these projects as items in <h:selectManyListbox>. When user selects one or more items and press submit button, selected items should be converted into projects. I'm confused a little about how to list items and how c...

How to efficiently (performance) remove many items from List in Java?

I have quite large List named items (>= 1,000,000 items) and some condition denoted by <cond> that selects items to be deleted and <cond> is true for many (maybe half) of items on my list. My goal is to efficiently remove items selected by <cond> and retain all other items, source list may be modified, new list may be created - best way...

Missing start boundary Exception when reading messages with an attachment file

Hi, I don't know why I'm getting the following exception when reading a mail with an attachment file from mail server: Exception in thread "main" javax.mail.MessagingException: Missing start boundary at javax.mail.internet.MimeMultipart.parsebm<MimeMultipart.java:872) at javax.mail.internet.MimeMultipart.parse<MimeMult...