Hello. Say I have a base form of a word and a tag from the Penn Treebank Tag Set. How can I get the conjugated form? For example for "do" and "VBN" how can I get "done"?
I'm trying to zip a large number of pdf files (stored as BLOBs in the DB) and then return the zip as an attachment to the user.
What's the best way to do this without running into memory issues?
Another note: I actually need to merge some PDFs prior to adding them to the ZipOutputStream. Therefore, a couple PDFs will need to be stored in memory at a time.
I assume it would be best to then store them as temporary files on the server before zipping them all?
Hi
I'm not too sure how to go about getting the external IP address of the machine as a computer outside of a network would see it. My following IPAddress class only gets the local IP address of the machine.
Any help would be appreciated.
Thanks.
public class IPAddress {
private InetAddress thisIp;
private String thisIpAddress;
private void setIpAdd(){
try{
InetAddress thisIp = InetAddress.getLocalHost();
thisIpAddress = thisIp.getHostAddress().toString();
}
catch(Exception e){}
}
protected String getIpAddress(){
setIpAdd();
return thisIpAddress;
}
}
I am trying to get the KeyListener working for Blackberry, but none of the Dialogs pop up indicating that a key has been pressed (see code below, each action has a dialog popup in them).
Any ideas on what i might be doing wrong?
public class CityInfo extends UiApplication implements KeyListener
{
static CityInfo application;
public static void main(String[] args)
{
//create a new instance of the application
//and start the application on the event thread
application.enterEventDispatcher();
}
public CityInfo()
{
//display a new screen
application = new CityInfo();
pushScreen(new WorkflowDisplayScreen());
this.addKeyListener(this);
}
public boolean keyChar(char arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
Dialog.alert("key pressed : " + arg0);
return true;
}
public boolean keyDown(int keycode, int time) {
// TODO Auto-generated method stub
Dialog.alert("keyDown : " + keycode);
return false;
}
public boolean keyRepeat(int keycode, int time) {
// TODO Auto-generated method stub
Dialog.alert("keyRepeat : " + keycode);
return false;
}
public boolean keyStatus(int keycode, int time) {
// TODO Auto-generated method stub
Dialog.alert("keyStatus : " + keycode);
return false;
}
public boolean keyUp(int keycode, int time) {
Dialog.alert("keyUp : " + keycode);
// TODO Auto-generated method stub
return false;
}
}
I also tried implementing keyChar on the MainScreen class but that did not yield any results either.
I want to create a program for generating the series for the given base-n. ,
for example if my input is 2,then series shuould be, 00,01,10,11,etc.,(binary)
if my input is 10,then series shuould be,1,2,3,4,5,etc.,(decimal)
is there any general mechanism to find these numbers so that I can program for base-n.,
Hi,
I am using simple date format to allow users to specify which time zone they are sending data in:
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,z");
This works fine:
e.g.
df.parse("2009-05-16 11:07:41,GMT");
However, if someone is always sending time in London time (i.e. taking into account daylight savings), what would be the approriate time zone String to add?
e.g. this doesnt work:
df.parse("2009-05-16 11:07:41,Europe/London");
Thanks.
If I have a try/catch block with returns inside it, will the finally block be called?
For example:
try {
something();
return success;
}
catch (Exception e) {
return failure;
}
finally {
System.out.println "i don't know if this will get printed out."
}
I know I can just type this in an see what happens (which is what I'm about to do, actually) but when I googled for answers nothing came up, so I figured I'd throw this up as a question.
Thanks!
Hi,
Is there any keyword or design pattern for doing this?
public abstract class Root
{
public abstract void foo();
}
public abstract class SubClass extends Root
{
public void foo()
{
// Do something
}
}
public class SubberClass extends SubClass
{
// Here is it not necessary to override foo()
// So is there a way to make this necessary?
// A way to obligate the developer make again the override
}
Thanks
I have to write a method that takes an array of ints that is already sorted in numerical order then remove all the duplicate numbers and return an array of just the numbers that have no duplicates. That array must then be printed out so I can't have any null pointer exceptions. The method has to be in O(n) time, can't use vectors or hashes. This is what I have so far but it only has the first couple numbers in order without duplicates and then just puts the duplicates in the back of the array. I can't create a temporary array because it gives me null pointer exceptions.
public static int[] noDups(int[] myArray) {
int j = 0;
for (int i = 1; i < myArray.length; i++) {
if (myArray[i] != myArray[j]) {
j++;
myArray[j] = myArray[i];
}
}
return myArray;
}
hi everyone,
I work on inheritence with GUI (graphical user interfaces)
let me explain for example I made super class which is vehicle and the subclass is car, so the code to make inheritence will be
public class Car extends Vehicle
then I want to build the class Car as JFrame like
public class Car JFrame implements ActionListener {
so the problem is that I couldn't put both codes in the same class, and I need to do that.
anyone help me. thanks in advance
I wish that the question would be clear
public class b {
public static void main(String[] args) {
byte b = 1;
long l = 127;
// b = b + l; // 1 if I try this then it does not compile
b += l; // 2 if I try this then it does compile
System.out.println(b);
}
}
I am using this code but I have problem:
I don't understand why b=b+l; is not compiling but if I write b+=l; then it compiles and runs.
Please explain why this happens.
I have 10 instances of the class movie which I wish to add to an Arraylist named Catalogue1
in a class containing a main method I write the following
ArrayList catalogue1= new ArrayList ()
//the class movie is defined in another class
Movie movie1= new Movie ()
Movie movie2= new Movie ()
Catalogue.Add (1, movie1)
What is wrong? Should I define somewhere what kind of Objects this arraylist named catalogue should contain?
Thank you in advance
I am trying to program a game in which I have a Table class and each person sitting at the table is a separate thread. The game involves the people passing tokens around and then stopping when the party chime sounds.
how do i program the run() method so that once I start the person threads, they do not die and are alive until the end of the game
One solution that I tried was having a while (true) {} loop in the run() method but that increases my CPU utilization to around 60-70 percent. Is there a better method?
Hey, I'm trying to take a simple image, something like a black background with colored blocks representing walls. I'm trying to figure out how to go about starting on something like this. Do I need to parse the image and look at each pixel or is there an easier way to do it?
I'm using Java3D but it doesn't seem to have any sort of built in support for that...
For a project, I have to convert a binary string into (an array of) bytes and write it out to a file in binary.
Say that I have a sentence converted into a code string using a huffman encoding. For example, if the sentence was: "hello" h = 00 e = 01, l = 10, o = 11
Then the string representation would be 0001101011.
How would I convert that into a byte? <-- If that question doesn't make sense it's because I know little about bits/byte bitwise shifting and all that has to do with manipulating 1's and 0's.
I want a simple class that implements a fixed-size circular buffer. It should be efficient, easy on the eyes, generically typed.
EDIT: It need not be MT-capable, for now. I can always add a lock later, it won't be high-concurrency in any case.
Methods should be: .Add and I guess .List, where I retrieve all the entries. On second thought, Retrieval I think should be done via an indexer. At any moment I will want to be able to retrieve any element in the buffer by index. But keep in mind that from one moment to the next Element[n] may be different, as the Circular buffer fills up and rolls over.
This isn't a stack, it's a circular buffer. Regarding "overflow": I would expect internally there would be an array holding the items, and over time the head and tail of the buffer will rotate around that fixed array. But that should be invisible from the user. There should be no externally-detectable "overflow" event or behavior.
This is not a school assignment - it is most commonly going to be used for a MRU cache or a fixed-size transaction or event log.
Hi
I wrote a webservice which runs correctly. In the webservice, there is a class which contains other classes' arrays and the webservice returns this class's instance. for example
public class cls1 implements Serializable{
cls2[] cls2Arr;
cls3[] cls3Arr;
}
I fill this arrays (cls2Arr and cls3Arr) correctly in service side. When I read this arrays from client, I see only last item of arrays. I checked on the service side before the webservice returns, and the cls1 instance and everything else looked good. What can be a reason ?
Thx
I need to be able to call a function, but the function name is stored in a variable, is this possible. e.g:
public void foo ()
{
//code here
}
public void bar ()
{
//code here
}
String functionName = "foo";
// i need to call the function based on what is functionName
Anyhelp would be great, thanks
I have a main class in a program that launches another class that handles all the GUI stuff.
In the GUI, i have a button that i need to attach an ActionListener to.
The only problem is, the code to be executed needs to reside within the main class.
How can i get the ActionPerformed() method to execute in the main class when a button is clicked elsewhere?
Hi,
I know how to use Ant to copy files and folders but what I'm interested in is if, and how, I can have the javac task copy the same sources it's compiling to the output directory.
Basically, it's very similar to the option to include your sources in the jar task.
Thanks in advance,
Ittai
I want to add a JComboBox in Swing that is simple but I want to assign the values for each items in combo. I have the following code
JComboBox jc1= new JComboBox();
jc1.addItem("a");
jc1.addItem("b");
jc1.addItem("c");
Now what I want is that when click on combo box it should return 1, 2 and 3 correspondingly
instead of a ,b, c.
Is there any way to assign the key values for each items in combo box?
Is anybody out there using Project Lombok for a large scale production system? How does it influence your compile process (i.e. does it do two-pass compilation, slow it down, make it more fragile)?
A JSpinner is used to store a number in my application (with a SpinnerNumberModel).
As expected, the spinner doesn't allow invalid characters (letters, symbols, etc.) to be stored. However, those characters do appear in the spinner component when I type them in. As soon as I switch the focus to another component, they disappear.
Is there a way to prevent invalid characters from appearing in the spinner?