So I have the following simple class that's designed to take a valid RSS feed and print it to file. When a valid RSS feed is given (whether a file is selected or not) everything works fine. But when an invalid RSS feed's fed through the XML object is supposed to return null. When that happens, I get a NullPointerException (which is fine if not for the fact that I've enclosed everything in if-else stuff). This is driving me crazy. I mean, NullPointerException in these things is common but usually I know what's throwing it and I can fix it but here I can't tell at all. (Error reporting system of PDE is pretty much crap, in my opinion). Anyway, here's the code:
//JOptionPane.showMessageDialog(null, "RSS Feed is not valid", "Invalid RSS Feed", JOptionPane.PLAIN_MESSAGE);
}
output.flush();
output.close();
}
else {
println("need a file");
}
}
}
PS: I have changed the order of things where the if statement to check whether rss is null or not encloses the rest of the ifs within and even that doesn't work. I know I'm screwing up somewhere, I just can't tell where exactly.
I am working on a Stemmer (implementation of Porter's Stemmer on Processing) that takes text files as input and takes the words and stems them down to their roots.
I have set it up so it has a GUI file chooser (JFileChooser) that helps the user pick a file from their computer and then the file is fed into FileInputStream (again with Java). Then the file is read character by character (or rather byte by byte) with the read() method and the words are then stemmed down to their roots. Here's the relevant code for the filechoose and the inputstream.
final JFileChooser fc = new JFileChooser();
int returnVal = fc.showDialog(this, "Open");
file = fc.getSelectedFile();
FileInputStream in = new FileInputStream(file);
This works perfectly and I have it set up the way I like. However, as the title suggests, what I am after is something like JFileChooser that I can use to enter URLs and then feed it to FileInputStream. I've been looking all over the place but haven't been able to find anything at all. I also realize I would need an HTML parser (maybe not?) but for that I have heard of something called TagSoup or something like that. Not sure that's the best way to go or not.
I'd really appreciate it if someone could help me out with these things.
Now, I realize that in the original Lilac Chaser, the circles disappear and appear in a way that they give the impression of a grey circle (and then a green circle) going around. I tried to create that by adding a background colored circle that goes around the 12 circles. But it ends up being pretty weird and not what I want.
I would really appreciate if you guys could help me out with this with ideas that I could try out. I am a noob at Processing so I would really appreciate it if your explanations were dumbed down for me.
PS: This is what I am trying to achieve in case you weren't familiar with the Lilac Chaser illusion:
Also I tried looking for a Processing implementation of Lilac Chaser over at openprocessing.org but couldn't find any. If you are familiar with such an implementation, I'd appreciate if you could direct me to it.
My question might sound really weird since the Reference guide's available online for all to say and if I can download the guide, why not just access it online (which is much faster). But the thing is, my internet has been acting up for the past week and I only get about a couple of hours internet every day. Since I am using Processing for my university and not just as a hobby, I can't afford to wait around for my internet to work to look up a reference.
So, my question is, is there a downloadable version of the reference guide or maybe a book I can buy that has all the references (kinda like Java stuff available to download or you can also buy a book "Complete Reference" or something like that)?
// when they let go of the key, reset the keyCode void keyReleased() { keyCode = -1; }
// this function checks if the ball has hit the top or sides of the bat and // updates its direction as appropriate so the ball bouncs off the bat // I have provided for a function here so that whenever the ball hits // the bat, it goes in the opposite direction. For more realism, I added // ballD/2, so the ball gets closer before it bounces off. // This function is still buggy as I have not been able to work those bugs // out. void checkBallAgainstBat() { if (ballX + ballD/2 > batX && ballX + ballD/2 < batX + batW) { if (ballY + ballD/2 - ballD > height-batH-ballD) { ballDy *= -1; } } }
// this function checks if the ball has hit the brick. It should bounce off // the brick and return true if so // This function is supposed to work as the checkBallAgainstBat() works // but for some reason it is all messed up and I can't seem to figure it // out. boolean checkBallAgainstBrick() { if (ballX + ballD/2 > brickX && ballX + ballD/2 < brickX + brickW) { if (ballY > brickH-ballD) { ballDy *= -1; return true; } } return false; }
// this function checks if the ball has hit the top, left or right // walls and update its // direction as appropriate so the ball bounces off the walls void checkBallAgainstWalls() { if (ballX + ballD > width) { ballDx *= -1; } if (ballX - ballD < 0) { ballDx *= -1; } if (ballY - ballD < 0) { ballDy *= -1; } }
The function that doesn't seem to work for me is:
// this function checks if the ball has hit the brick. It should bounce off // the brick and return true if so // This function is supposed to work as the checkBallAgainstBat() works // but for some reason it is all messed up and I can't seem to figure it // out. boolean checkBallAgainstBrick() { if (ballX + ballD/2 > brickX && ballX + ballD/2 < brickX + brickW) { if (ballY > brickH-ballD) { ballDy *= -1; return true; } } return false; }
I have played around with it, I have done so much to it I can't even remember. I still can't figure out why it acts weird. I don't want the brick to disappear or anything, I will work on that later. All I need to know is why this function isn't operating as normal and how I can fix it.
I'd really appreciate a detailed reply on this as I have been working on it for weeks, literally.