I'm trying to read UTF-8 from a text file and do some tokenization, but I'm having issues with the encoding:
try {
fis = new FileInputStream(fName);
} catch (FileNotFoundException ex) {
//...
}
DataInputStream myInput = new DataInputStream(fis);
try {
while (thisLine = myInput.readLine()) != null) {
StringTokeniz...
Let's say I have a Person class that has a collection of Dog objects. The relationship is bidirectional.
public class Person {
private List<Dog> dogs;
// getter and setter for dogs
}
public class Dog {
private Person person;
// getter and setter for person
}
Ok now if I was just working with these objects, I would have metho...
I have an input ByteArrayOutputStream and need to convert that to a CharBuffer.
I was trying to avoid creating a new string. Is there anyway to do this.
I was trying to do the following, but I don't have the encoding for the string so the code below will not work (invalid output).
ByteBuffer byteBuffer = ByteBuffer.wrap(byteOutputStr...
Hi Gurus,
I have to call this webservices which is a .net web services (well.. WS should be pretty platform independent I guess) I have attached the WSDL below.
I am using Spring WS 1.5.6. I am not sure what to put in the message.
Do I have to include the namespace etc? and Do I need to specify the method name etc?
(Second thought i...
Can anyone recommend a tutorial on how to write a Java Servlet which connects to MS SQL server and manages data?
I'm trying to write something which pulls products out of one database and inserts them into a stored procedure located on another database.
Thanks in advance.
...
I am in process of building up a small framework that does unit testing for JSPs. These JSPs have some custom tags, otherwise they are not any special.
Although there are numerous Java unit testing solutions available, I prefer not to use the method where a separate full-blown JSP container is launched, application deployed and results ...
I am trying to telnet into a server using Python on Windows XP. I can connect successfully by typing 'telnet HOST PORT' which creates an anonymous connection. But Python's telnetlib.Telnet(HOST, PORT) returns 'Connection refused'. Telnetting in Java also fails. Spelunking shows that Python tries to create an anonymous socket connecti...
What could be a good way to code a search functionality for searching documents in a java web application?
Is 'tagged search' a good fit for such kind of search functionality?
...
Thank you all for your help. A number of you posted (as I should have expected) answers indicating my whole approach was wrong, or that low-level code should never have to know whether or not it is running in a container. I would tend to agree. However, I'm dealing with a complex legacy application and do not have the option of doing a...
I have a data object represented in a TreeModel, and I'd like to show only part of it in my JTree--for the sake of argument, say the leaves and their parents. How can I hide/filter the unnecessary nodes?
...
BlockingQueue has the method called drainTo() method but it is not blocked. I need a blocking queue that I want to blocked but also able to retrieve queued-object in a single method.
Object first = blockingQueue.take();
if ( blockingQueue.size() > 0 )
blockingQueue.drainTo( list );
I guess the above code will work but I'm look...
I'm looking for something like dom4j, but without dom4j's warts, such as bad or missing documentation and seemingly stalled development status.
Background: I've been using and advocating dom4j, but don't feel completely right about it because I know the library is far from optimal (example: see how methods in XSLT related Stylesheet cla...
I'm running a Tomcat server with some virtual hosts and I need to POST some data to a servlet on this server from another servlet on another server. Because the server that I am POSTing to uses virtual hosts just referring to this host by it's IP address will cause problem (it won't know what virtual host I'm trying to talk to).
Here i...
Upon reviewing a bunch of MVC style web applications, I'm noticing that it's common to have a very large service interface sitting in front of the business layer. The implementation of this interface usually includes a bunch of DAOs. So you have something like:
public class FoodServiceImpl implements FoodService {
private FruitDAO ...
We're trying to cluster a COMET web application written in Java using JETTY 7.0's implementation of suspended servlet 3.0 API.
Does anyone have experience using Terracotta in a suspend/resume servlet web application.
Greg Wilkins of JETTY mentions some issues with COMET performance with Terracotta.
Clustering COMETD with Terracotta
...
I have a method that does a bunch of things; amongst them doing a number of inserts and updates. It's declared thusly...
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false)
public int saveAll(){
//do stuff;
}
It works exactly as it is supposed to and I have no problems with it. There ar...
We are just starting to build our JMS architecture and have the following basic setup:
GLassfish v2.1
MDB listening on a Topic through a TopicConnectionFactory (all on local server)
Now, the MDB spawns a worker thread when a new message arrives and even though we have in order delivery of messages, we need a synchronization mechanism...
Is there an existing Java library which provides a method to strip all HTML tags from a String? I'm looking for something equivalent to the 'strip_tags' function in PHP.
I know that I can use a regex as described in this Stackoverflow question, however I was curious if there may already be a 'stripTags()' method floating around somewh...
I'm in the processes of changing my DAO layer from using Hibernate API to using a pure JPA API implementation. It looks like the recommended method is to use the createNamedQuery from the entity manager. The named queries are stored in annotations in the model/entity classes. This just not makes sense to me. Why would you define the ...
I'm thinking about using the java application object to implement a simple cache, to save a few configuration variables, and a couple of xml with often used info...
I'd like to know where is the application data phisically stored (a system file, in memory, db), how can it be configured, and if there's any kind of limitation, like space,...