So I know about String#codePointAt(int), but it's indexed by the char offset, not by the codepoint offset.
I'm thinking about trying something like:
using String#charAt(int) to get the char at an index
testing whether the char is in the high-surrogates range
if so, use String#codePointAt(int) to get the codepoint, and increment the...
Hello I have written a such function under Eclipse:
public static ArrayList<String> getMails(){
ArrayList<String> mails = new ArrayList<String>();
try{
FileInputStream fstream = new FileInputStream("mails.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedRea...
Hi all,
This line of code, which decodes an encoded Chinese word:
URLDecoder.decode("%E4%BB%BB%E4%BD%95%E8%BD%A6%E8%BE%86%E5%BA%94",
"UTF-8").getBytes().length
When I run it in a JSP page (on Jboss) it prints 5:
<%= URLDecoder.decode("%E4%BB%BB%E4%BD%95%E8%BD%A6%E8%BE%86%E5%BA%94",
"UTF-8").getBytes().length %>
Running...
Hey I'm trying to figure out how to do Basic Authentication with an ADB Axis2 version 1.5 Client.
I'm trying the following:
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
basicAuth.setUsername(username);
basicAuth.setPassword(password);
final Options clientOptions = servic...
The SWIG documentation explains how a variety of input types in C, like this:
void spam1(Foo *x); // Pass by pointer
void spam2(Foo &x); // Pass by reference
void spam3(Foo x); // Pass by value
void spam4(Foo x[]); // Array of objects
... would all take a single type of argument in Java, like this:
Foo f = new Foo...
Hey there,
I want to dynamically reference an XSD from a bean, how is this possible? I already added the XSD to the project, so it's located somewhere in the GlassFish domain.
Any thoughts will be appreciated!
Daniel Szalay
...
Is there anything I can cast a boolean array to in Java? It would be nice if I could say
boolean[] bools = new boolean[8];
int j = (int)bools;
But I'm not sure if that's feasible in Java.
...
Hi
I am brand new to Spring web MVC. I am trying to create a simple 1 paged site that will check the users browser and display the current theme for that browser.
If its a mobile app, I need to allow the user a button to switch to the regular site.
Also the current theme for mobile and non-mobile is stored in a database, which inclu...
Is there a recommended way to synchronize Tomcat Servlet instances that happen to be competing for the same resource (like a file, or a database like MongoDB that isn't ACID)?
I'm familiar with thread synchronization to ensure two Java threads don't access the same Java object concurrently, but not with objects that have an existence ou...
Simple JPA/JPQL question. I have an entity with a ManyToMany relationship:
@Entity
public class Employee {
@ManyToMany
@JoinTablename="employee_project"
joinColumns={@JoinColumn(name="employee_id"}
inverseJoinColumns={@JoinColumn(name="project_id"})
private List<Project> projects;
What is the JPQL query to retu...
Hi,
I am just curious but I want to know if it is feasible to remove totally the Java standard class libraries coming with the JVM and start a new one from the scratch [à la ClassPath].
If that is possible, what classes MUST be implemented as minimum? (Object and String come to my mind, but... I do not know).
Such thing breaks some li...
Suppose I have classes like:
class A {
B getB();
C getC();
}
class B {
String getFoo();
}
class C {
int getBar();
}
and I want to filter criteria on A, two filters on different subclass properties, like:
Criteria criteriaA = session.createCriteria(A.class);
Criteria criteriaB = criteriaA.createCriteria("b").add(Restrictions.eq(...
I have a web application running in tomcat where I'm using a ThreadPool (Java 5 ExecutorService) to run IO intensive operations in parallel to improve performance. I would like to have some of the beans used within each pooled thread be in the request scope, but the Threads in the ThreadPool do not have access to the spring context and ...
How to save drawing in JComponent into tiff format? I only know how to save the whole Java file but I dont know how to save specific Jcomponent. Help me :-(
EDITED:
Thanks guys, now I am able to save my drawing to Jpeg.
However I just wanted to save one of the component? The c.paintAll(bufferedImage.getGraphics()); seem to save the wh...
In Java 6, is it possible to inject some value into a (@Target(ElementType.PARAMETER) and @Retention(RetentionPolicy.RUNTIME)-meta-annotated) method parameter?
It's entirely possible to find the annotation at runtime using reflection, it's just that there seems to be no way of actually modifying the parameter's value.
Or is that strict...
Anyone know if it's possible to enable/disable individual JFace TextCellEditor fields.
For instance if I have a table with 5 columns, I want the last cell to be empty unless field #4 is filled in.
...
I've managed to enable access logging in Tomcat by editing the conf/server.xml and uncommenting the entry for the org.apache.catalina.valves.AccessLogValve Valve. I'd like to be able to dump the contents of POST's payload. It doesn't seem like any of the options in the pattern will do this. Is there a built in way to do this? Do I use th...
I have two separate databases that contain a report and reportItems table. The table structure is the same for both databases.
I have a session bean that needs to write to each database / table. In order to keep the code simple I want the session bean to work with a base entity bean that then goes to the appropriate table.
To accomplis...
Is there a simple way to draw underlined text in draw2d without manually drawing a line under the text?
...
I've got the following line in my pom.xml:
<updateRepositoryURL>file:/${user.home}/.m2/repository/repository.xml</updateRepositoryURL>
and when I am attempting to use it within my program the resultant string is:
file:/c:Documents and Settings<myusername>/.m2/repository/repository.xml
where <myusername> is my user name funnily enou...