Is there a simple way to turn the standard code:
in = new InputStreamReader(socket.getInputStream());
String message = "";
while ((size = in.read(buf)) != -1){
message += new String(buf, 0, size);
}
so that read() won't block. I tried doing:
if (!in.ready())
//throw exception
but this throws an exception all the time. Maybe...
I am trying to build an ANTLR grammar that parses tagged sentences such as:
DT The NP cat VB ate DT a NP rat
and have the grammar:
fragment TOKEN : (('A'..'Z') | ('a'..'z'))+;
fragment WS : (' ' | '\t')+;
WSX : WS;
DTTOK : ('DT' WS TOKEN);
NPTOK : ('NP' WS TOKEN);
nounPhrase: (DTTOK WSX NPTOK);
chunker : nounPhrase {System.out....
Sorry for the poor title, can't think of a succinct way of putting this..
I'm thinking of having a list of objects that will all be of a specific interface. Each of these objects may then implement further interfaces, but there is no guarantee which object will implement which. However, in a single loop, I wish to be able to call the me...
Hi,
with native SQL I get the database time with a statement like:
SELECT CURRENT_TIMESTAMP
with JPQL I get the same result with:
SELECT CURRENT_TIMESTAMP
FROM Customer c
WHERE c.id=1
Is there a way to get rid of the last two lines?
thanks,
...
String product = Integer.toString(w);
char[] original = String.toCharArray(product);
This is the code I have so far. The error says that I can't use toCharArray on String, but I looked in the documentation, and it is a listed method, so I'm kind of stuck.
...
Currently, I'm simply inserting the word into the dictionary (ArrayList<String>) and then sorting the dictionary like so:
dictionary.add(newWord);
Collections.sort(dictionary, new Comparator<String>(){
public int compare(String s1, String s2) {
return s1.compareToIgnoreCase(s2);
}
});
I'm trying to determine wh...
I'm writing a Maven plugin and I am using default values for all parameters such as this:
/**
* The file with the site structure.
*
* @parameter expression="${generateSite.siteFile}" default-value="${basedir}/src/oda/site.xml"
*/
private File siteFile;
Now I am adding a new parameter which is a collection. Is there a way to set d...
Hi, this is my first time using StAX for parsing XML documents (still in the learning stage). During the process to parse an XML document using XMLStreamReader and generate a copy of the document using XMLStreamWriter, I encountered the following warning represented as a comment in the output of the writer:
<!-- Exception scanning Ext...
Hi guys,
I'm developing both a Java app and J2EE webapp using Eclipse Europa on Mac OS X 10.5.8. The webapp provides a RESTful API layer for the Java app I've written. I'm running the webapp using tomcat from inside Eclipse.
It seems like there are some serious performance issues and I would like to use a profiler to narrow down on th...
I have the following iBatis mapping for an Oracle Stored Procedure that returns a true/false value.
<resultMap id="isAuthorizedResult" class="java.lang.Boolean">
<result property="isAuthorized" column="isAuthorized"/>
</resultMap>
<parameterMap id="isAuthorizedCall" class="map">
<parameter property="prgType" jdbcType="Str...
Android 2.0 has turn-by-turn directions, however, I do not yet see an API exposed for this in the 2.0 SDK. Are there any documented plans to expose an API for calling into the new turn-by-turn features?
...
I'm trying to run jetty without building the whole project, but simply point jetty to a folder under the target folder. Reason behind doing this is that I wish to use jetty as a static content server while i build application for glassfish. i don't want to redeploy all the time when i make a little change to a css file, for example.
Whe...
Hello, I have a Java socket server that is expecting exactly n bytes from some port. I want to write a Python clients that just sends bytes on some port to the Java server.
Since Python does not have primitives, I'm not sure to send exactly n bytes. Any suggestions?
More details:
I have a Java DatagramSocket that takes in n bytes:
Da...
To my endless disbelief I discovered the .NET stack doesn't have the answer for everything. Is there a software parallel to WCF (Windows Communication Foundation) in Java or is WCF the only WCF out there.
...
i am trying to upload a file into the server and storing the information of the file into an Access database, is there any need to handle the threads while database connectivity for multiple user. If yes how to do it?
...
Hello,
Part of an app I am working on includes a log file viewer, with a find text function, which calls a pattern matcher on JTextField#getText(), like so:
Matcher m = somePattern.matcher(textField.getText());
m.find(startPosn);
System.out.println("startPosn: " + m.start());
System.out.println("endPosn: " + m.end());
where textField...
i am writing standalone java app for production monitoring. once it starts running the api is configured for default values which is set in .properties file. in running state the api's configuration can be changed and the .properties file should be updated accordingly. is there a way to achieve this ? or are there any other approaches to...
Java and .NET are two languages targeted at removing platform dependence. This is achieved by adding a virtual machine/framework between the code and the OS.
So, what is the point in using it on the server side, as all websites are accessible via browser, and that is platform independent? Is there any special reason for using them?
...
Can anyone give me some idea about uploading data from excel to access database using java
...
I want to pop up a dialog box that says "Saving..." and once the operation is completed, it simply disappears. While the saving is in progress, I dont want the user to be able to do anything. I also dont want an OK button.
What is the name of the Java class that allows me to do this?
...