For example, lets say you have two classes:
public class TestA {}
public class TestB extends TestA{}
I have a method that returns a List<TestA> and I would like to cast all the objects in that list to TestB so that I'd end up with List<TestB>.
...
Cryptography newbie here... I'm trying to do 128-bit encryption using BouncyCastle with the code below.
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.KeyStore;
import java.security.Security;
import java....
Hiya guys!! This is my first post, and this is for a school project; I'm running into a huge amount of trouble, and I can't seem to find a understandable solution.
a b c d e z
a - 2 3 - - -
b 2 - - 5 2 -
c 3 - - - 5 -
d - 5 - - 1 2
e - 2 5 1 - 4
z - - - 2 4 -
Thats the two dimensional array. So if you want to find the shortes...
I found BigDecimal have setScale method, but doesn't have getScale method. How to getScale on BigDecimal?
...
If I'm presenting code usually I show it in a syntax-highlighting text editor. But I've been doing more "live coding" in some presentations recently where it's important to show off some IDE tooling.
How should I set up Eclipse when preparing for a presentation or demo?
Is there a way to save and switch out
presenter settings?
Is the...
What is a use case for using a dynamic proxy?
How do they relate to bytecode generation and reflection?
Any recommended reading?
...
I would like to create an initialisation method for a Java class that accepts 3 parameters:
Employee[] method( String[] employeeNames, Integer[] employeeAges, float[] employeeSalaries )
{
Employee myEmployees[] = new Employee[SIZE];// dont know what size is
for ( int count = 0; count < SIZE; count++)
{
myEmployees[c...
I would like to spawn a subprocess Java Virtual Machine (through a Java API call) and communicate with it.
Maybe I'm just not searching for the right thing on Google, but I keep getting pointed back to Runtime.exec(), which is not what I want. I know I could connect standard input/output and use various serialization techniques, or use ...
private static Callback callback;
public Foo()
{
super(getCallback());
}
private static Callback getCallback()
{
callback = new Callback();
return callback;
}
Constructor Foo() can potentially be called from multiple threads. My concern is with the private static field 'callback' and the static method 'getCallback()'.
A...
Hello,
I'm using Hibernate second level cache in my application, for certain business reason I can't change the entity annotation any more.
In my project, apart from changing the Database from Hibernate, there exist also other native SQL that do not go through Hibernate. Therefore, the Hibernate second-level cache data could be stale a...
I'm writing a program in scala which call:
Runtime.getRuntime().exec( "svn ..." )
I want to check if "svn" is available from the commandline (ie. it is reachable in the PATH).
How can I do this ?
PS: My program is designed to be run on windows
...
Hibernate persistence class:
@Entity
public class A {
@OneToMany(mappedBy = "a")
private Set<B> bSet = new HashSet<B>();
@Basic
private boolean DELETED;
}
Class B also have a DELETED property. How can we process DELETED property during join automatically, for select only not deleted entities.
May be with hel...
I want to write a very simple game in Java to demonstrate a wireless controller I've built. I thought of something like Breakout or Pong. Currently, I have a prototype Pong implementation that does all animation directly using the AWT functionality. However, this is somewhat awkward to program and also a major CPU hog.
My question:
Can...
I just start integrate Hibernate Search with my hibernate application. The data is indexed by using Hibernate Session everytime i start the server.
FullTextSession fullTextSession = Search.getFullTextSession(session);
Transaction tx = fullTextSession.beginTransaction();
List books = session.createQuery("from Book as book").list();
for...
I'm using a convention of prefixing field names with an underscore. When I generate annotate entity classes with such fields I am stuck to using the underscore-prefixed property names in queries. I want to avoid that, and be able to do:
@Entity
public class Container {
private String _value;
}
// in a lookup method
executeQuery("f...
I am using a random access file in which i want to delete a line which satisfies some condition like if i have records
MCA 30
MBA 20
BCA 10
now my requirement is if i enter MBA then second line is to be deleted.
...
I'm trying to filter out all possibilities of XSS from user name input while still allowing for foreign names to be inputted.
What is the best way to white-list all word-characters in multiple languages (also Chinese and Japanese and Russian)?
Is this possible at all? It would be easy to create a blacklist for XSS with "<>><" but...
In python, if I have a few functions that I would like to call based on an input, i can do this:
lookup = {'function1':function1, 'function2':function2, 'function3':function3}
lookup[input]()
That is I have a dictionary of function name mapped to the function, and call the function by a dictionary lookup.
How to do this in java?
...
Okay, I think I already know, but I want to make sure, and this surprisingly simple question was surprisingly hard to google. :P
In the tomcat manager, I have some session stats, like so:
Active sessions: 1 Session count: 1 Max active sessions: 1 Rejected session creations: 0 Expired sessions: 0 Longest session alive time: 0 s Average ...
Here's I want to do, I want to upload a file that will be processed by a servlet. I would use Apache Commons - File Upload to handle the file to be uploaded.
I've seen the gmail-like AJAX file upload, where there would be a hidden iframe that would later be populated with a javascript to stop showing the upload image or displaying a mes...