java

Java InputStream != Readable

I am using java.util.Scanner for things such as nextInt(), and all was working fine as long as I was using a java.lang.Readable (one and only constructor argument). However, when I changed to using an InputStream instead, Scanner.nextInt() never returns. Do you know why? My implementation of the InputStream looks like this: private sta...

How can I know what exceptions can be thrown from a method?

How can I know what exceptions might be thrown from a method call? ...

Netbeans: Is there a way to mimic Eclipse CTRL+H looking for usages in JRE and Application Libraries ?

Hi, See Eclipse Java Search screenshot . I googled a lot, tryied my best but could not find any ways to tell Netbeans to search for method invocation in JRE / Application libraries. Let's consider: I have maven project with ApplicationA being runtime ApplicationA* artifat defines interface InterfaceA with method methodA I'm impleme...

How to inherit from multiple base classes in Java?

Possible Duplicates: Cheat single inheritance in Java !! Why is Multiple Inheritance not allowed in Java or C#? Multiple Inheritance in java. I know that we can use interfaces to inherit from multiple classes but is it possible to inherit the state as well? How can I inherit methods with definitions from 2 classes and have t...

Number wrapper classes in Java

Im coming from PHP world and im so confused about how to think when you declare objects in java. so when traditionally you do like this: Rectangle rect = new Rectangle(); cause rect is a Rectangle datatype. According to the java tutorial page a number wrapper class is a subclass to Number. So its a class but when you instantiate it...

Java regular expression OR operator

This may be a dumb question, but I couldn't find it anywhere: How can I use the java OR regular expression operator (|) without parentheses? e.g: Tel|Phone|Fax ...

Passing a variable's value not reference in an OnClickListener()

Hi, I'm trying to set up a large number OnClickListeners through a for loop. Each view should run a method when clicked; view 0 should run the method with the value 0, view 1 with the value 1, etc. However, if I declare the OnClickListener using a variable which increments through the for loops, the OnClickListener remembers the referen...

Why does this error occur when I try to run a Junit test-case on the Android emulator?

After following some instructions on Diego Torres blog I am able to test my classes using the regular Eclipse JUnit test-runner, however I also want to be able to run my unit tests from within the emulated android environment. For now this should make no real difference since the classes I am working on do very basic numerical or netwo...

code errors copying from a book

The code comes from "Hello Android" Page47. I am using 1.6 since that is what the book is written for. import android.app.Activity; import android.os.Bundle; import android.content.Intent; import android.view.View; import android.view.View.OnClickListener; /** Called when the activity is first created. */ e1 @Override e2 publ...

Has Google Collections 1.0 been mavenized?

According to the entry at MVNRepository, at the time of this writing, the latest version in maven central is 1.0-rc5. I am aware there are no changes between 1.0 which was recently announced and RC5, but I guess the nit picker in me wants to find a 1.0 version. Here's the POM entry for RC5. <dependency> <groupId>com.google.collect...

Java.NIO InvalidIndexException - how to read and write with random access to large files.

I've created a java.nio.MappedByteBuffer around a java.io.RandomAccessFile (a file which is only 54 KB in size). The resulting MappedByteBuffer has a "capacity" and "limit" of around 12 KB, so when I try to invoke mybytebuffer.get(i > 13044) or mybytebuffer.put(i > 13044, value) it throws an InvalidIndexException. All of this behavior i...

how to calculate the most used apps-android

So I'm developing an app for android, and before I get too much into it, I want to conceptually get my arms around what I am trying to do. Is it very difficult to calculate or track the most frequently accessed apps? Any ideas or insights about how I might go about getting this done would be greatly appreciated! I'm used to iphone develo...

no ordinary "function" in java?

in php you can declare a function in a global scope with function. is this not possible in java? looks like every function is in a class as a method. so everything is OOP in java? no procedural code? ...

Why cant I override onConfigurationChanged?

Hey, im trying to override the method onConfigurationChanged and I get the error: The method onConfigurationChanged(Configuration) of type BaseActivity must override or implement a supertype method Here is my BaseActivity.java: import android.app.Activity; import android.content.Intent; import android.view.View; import android.view.Vi...

Is there an implementation of org.apache.commons.lang.StringEscapeUtils for .Net?

I'm porting over a Java project that I wrote which uses the Apache Commons StringEscapeUtils class (particularly the escapeXml unescapeXml escapeHtml unescapeHtml methods). Is there a .Net equivalent? Or perhaps some totally logical bit of C# code that accomplishes the same thing? ...

checking words in a dictionary

I need to determine if an unknown 5 or 6 letter string is a valid word, i.e. is in the dictionary. I could submit the string/word to an online dictionary, but I need to check this string/word, which will be different each time, for about 100 to 150 times. This seems to be a bit time consuming. My next thought would be to try to get a di...

Making an Unfocusable Window in Java

(SOLVED: a WindowStateListener and a deferred call to toBack whenever the window is focused) Hello all! I've been trying to figure out how to make a java.awt.Window (any subclass will do) so that it cannot be brought to the front. I'm working on a Java "Samurize-like" program that appears below all the application windows and displays ...

password protection of pdf files

we have a requirement to protect pdf files using a password, are there any java based open source tools which will help us in this regard? ...

Is the SCJP CX-310-065 exam divided into the objectives (sections) as outlined on Sun's site?

The objectives and sections are listed here: http://www.sun.com/training/catalog/courses/CX-310-065.xml I've been using the Sun Certified Programmer for Java 6 Study Guide, which lists objectives as well that are close to those on the Web site, but they also have "sub-objectives" in the book that appear to be somewhat manufactured. Wil...

add file to collections framework from file

I am not trying to duplicate threads here. My problem is i am piping in a file using msdos called amazon.txt the file has 637 words in it.. I want a count of unique words.. and not a count of "a", "the" , "this" which i havent counted for yet in the code.. when i add to a tree set it only has 8 words.. There should be atlest 300 unique ...