« first day (1355 days earlier)      last day (3572 days later) » 

2:43 AM
Greetings dear sirs, a quick question... What are the differences for catch(final ExceptiontoCatch ex) and catch(ExceptiontoCatch ex)?
Or more specifically, what are the differences when I use final keyword for the Exception in a catch block
 
 
10 hours later…
12:47 PM
Good morning, Java!
 
Greetings
I was looking for you!
1st: How are you?
 
hi, does anyone know how to check for a number on a char? i'm trying to use regex but that only works on strings
 
My first thought is to check the ASCII value of the char, if it's in the rang...
@Michael [Those comments were directed towards you]
 
@aliteralmind What version of JUnit do you have? ez-vcard uses 4.11 which, according to Maven, is the latest version.
Sorry, was catching up on the chat history.
I'm fine, how are you?
@Eggy The \d keyword will match a numeric character.
@Unihedron I'm pretty sure it just means that you can't reassign the variable to another object (just like any other "final" variable). But maybe it has a special meaning in Java 8, I don't know.
@aliteralmind Yep: search.maven.org
 
hi michael, so how would u do it? .matches("\d") ?
 
12:57 PM
@Eggy Well, you have to escape the backslash character, because this is a Java string.
So it would be .matches("\\d").
 
man, they've given me a task for a job interview. this is for an internship. the struggle is real
 
Good luck. :)
 
lol yeah, I'm gonna need it. thanks for the help michael. it's just at uni we haven't done anything like this so yeah
so sorry if I'm being annoying
 
No problem. Just don't expect us to give you answers. :P
 
^^
 
1:13 PM
@aliteralmind Ah, I see what's going on. It is encoding the "\r" character for XML.
 
@Michael 4.8.2. The only thing I've encountered that makes it incompatible with 4.8.2, is tempFile(). The no-param version isn't in 4.8.2. Changing it to tempFile("TEMP")seems to be all that's necessary to make it work in both versions.
 
I think I'll have to stick with using a hard-coded "\n" line separator.
 
@Michael Why not System.getProperty("line.separator", "\r\n")?
 
@aliteralmind 4.8.2 isn't the latest version. 4.11 is. :P
 
Oh. You're kidding
 
1:15 PM
<offtopic> @Michael, grats on 9001 rep
 
@aliteralmind Because the XML writer replaces the "\r" characters with "&#13;". That's why the unit test was failing.
 
@Michael Sorry. Multi-tasking.... Have you played with my game at all since we last talked about it?
 
@Unihedron lol! Thanks.
@Karl No, I just played with it when you emailed it to me.
 
Rats...
I wonder about how addictive it is. It might be because of how challenging it is...
 
@Karl: Curious!
 
1:30 PM
@aliteralmind Same problem as before. I forgot to apply the fix to other places.
Changes committed.
@aliteralmind You are now officially a contributor! :P
 
Sweeeeeheeheheheet.
 
Thanks for finding those bugs.
 
@Michael You're welcome.
Making my projects Maven Central compatible is a big deal. Can't be implemented into ez-vcard until it is.
 
This is assuming the unit tests pass now. xD
 
Going to take a while.
 
1:36 PM
Ah ok.
 
Using your downloads page as inspiration.
 
I wrote a blog post about uploading a project to Maven Central. It might be helpful to you (though, it assumes you are using Maven as your build tool): mangstacular.blogspot.com/2012/10/…
:D
 
(One big advantage of code.google over github is the really nice results google gives you when searching for "ez-vcard".)
 
Haha, well I'd like to think that Google doesn't treat code.google.com any differently from other websites.
 
@Michael Will take a look. I was Ant-only as of yesterday
 
1:38 PM
If you want to try an even newer build tool, gradle is very popular.
I don't know much about that though.
Gradle uses Maven's dependency management architecture, so it plugs into Maven Central.
But other than that, it's totally different.
 
@Michael Searching for largetext fge, searching for ez-vcard
Your results are so much cooler.
 
Ah, true.
 
@Michael Heavily invested in Ant. Need to finish this before looking more into gradle. Gradle seems like a good alternative though.
 
Ah, ok.
 
need some help on jSf
can anyone help me
anyone
?
 
1:47 PM
Sorry, not familiar with JSF.
 
mmmmm
 
@NTK88: Same here :(
 
ok tnx guys
 
2:07 PM
I like Make!
@NTK88 i dunno wat jsf is
oh he's gone
 
3:07 PM
I hate when I drift off this site and things happen that I'm interested in...
 
3:39 PM
I am in need of help with SWT and this layout that I have been trying to get to work for [literal] days
 
 
2 hours later…
5:13 PM
Hmm, hey guys. I'm trying to copy the first line of a text file onto another file. Any help please? So far I've tried for (int i = 0; i<line.length(); i++) {
while (line.charAt(i) != '\n') {
String line = line.substring(0,i);
}
}
with no success
 
5:41 PM
you're re-using line as a variable
but regardless
There's a much better way to do that
 
yeah, sorry just noticed that
 
look at BufferedReader
It will split things into lines for you
so you don't have to find the \n
 
ok thanks
 
so (assuming you are using a FileInputStream) to read your file:
BufferedReader myBufferedReader = new BufferedReader(new FileReader("FILENAME.TXT"));
String line = myBufferedReader.nextLine();
while(null != line){
//do something with line
line = myBufferedReader.nextLine();
}
 
ok thank you I'll try it on my code. Can I ask one more question if you don't mid please?
 
6:04 PM
I've got this crazy JSP compile error. Think anybody could help me troubleshoot?
Been struggling for most of the day.
Short story: Got existing project that runs GWT 2.5.1 web app. I'm reworking it to integrate Maven. Finding lots of strange issues with JSP since.
First, JSPs were all failing to compile because it seems to be running under JRE 1.4 even though everything is set to 1.7 and it worked before.
So I suspected upgrading to GWT 2.6.0 would help because it provides a newer version of DevMode which provides a newer Jetty server that ought to support JSP better.
It builds with GWT 2.6.0, but accessing any JSP always fails with exception org.apache.jasper.JasperException: Unable to compile class for JSP
No other messages to help pinpoint the issue.
 
6:23 PM
Accessing any asp?
JSP
And were these working previously, or are they all there?
all new, I mean
 
Any JSP. Even a blank file.
No changes to existing JSP code.
Seems Maven really mucked stuff up for Eclipse.
But really all I did was form my pom.xml to reference all dependencies. Removed static dependencies from WEB-INF/lib.
Converted project to Maven project.
Eventually got it to compile ok.
But JSP has been broken since
Builds ok from "mvn clean compile package", too.
 
do you get a stack trace? Usually they will tell you where in the JSP it's broken
 
Got some other new errors that may be related from log4j:
log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [sun.misc.Launcher$AppClassLoader@430e468f] whereas object of type
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebAppClassLoader=IMPACT tool@2da0d41b].
log4j:ERROR Could not instantiate appender named "CONSOLE".
Seems to indicate a duplicate log4j jar on classpath, but I can't find any evidence of that.
 
Jar hell :(
when you run maven there's a way to run in debug mode which usually dumps the full classpath
 
I do get a stack trace. Here's the header
 
6:32 PM
try running it like
maven ARG -X
 
[WARN]
org.apache.jasper.JasperException: Unable to compile class for JSP
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
 
(only for maven >= 3)
What container are you using? Tomcat?
Netty?
Sometimes the class path doesn't include the tools.jar and you need to manually copy it to the lib dir of the container
but that's a rare case
 
Tomcat on deployed environments. Debug in GWT DevMode (Jetty).
Let me see if it works on Tomcat.
 
You're pretty much out of my knowledge now. I'm not up on Maven
 
I'd really like to get out of GWT.
It really complicates stuff.
Hmm, new error
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/commons/el/ExpressionEvaluatorImpl
 
6:38 PM
Definitely class path issues
 
Hmm, that class comes with gwt-dev-2.6.0.jar That should've been deployed
 
7:00 PM
how to take input from UVA?
 
hey kylar I've done what you asked and it worked. However I have a new problem :/
 
7:53 PM
Of course you do.
 
 
1 hour later…
9:00 PM
This may sound didactic, but when you say "I have a problem" and then disappear instead of actually stating your problem, people are less likely to help you. Ask your question immediately instead of waiting for someone to acknowledge that they are present.
 
 
2 hours later…
11:05 PM
Hi
 
Zzzz
 
Can I ask you guys a question?
Java-related of course
I am overloading a HashMap such that whenever you add to it, if a value exists it drops the old key and then updates
is this a good way of iterating through values? / are there any ways to make this more performant?
 
So, basically what a HashMap already does?
 
static class UniqueHashMap<K, V> extends HashMap<K, V>
    {
        public V put(K key, V value) {
            if (containsValue(value)) {
                Iterator iterator = entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry pairs = (Map.Entry)iterator.next();
                    if (value.equals(pairs.getValue())){
                        remove(pairs.getKey());
                        break;
                    }
                }
            }
 
Oh dear God no
 
11:07 PM
ok so how is it done lol
i come from C#
 
a HashMap will overwrite automatically when you do a put(K,V)
 
greetings
 
Whatever you use as a key should have a proper implementation of equals()
 
yes but i am overwriting the keys
if the same values exist
example....
 
Then the old value will be dropped
HashMap<String, String> myMap = new HashMap<>();
myMap.put("Name", "Alex");
myMap.put("Name", "Tom");
 
11:09 PM
if it has "aaa" -> "bbb", and you put "ccc" -> "bbb", it will delete "aaa" and you will be left with "ccc" -> "bbb"
 
That's a reverse map
Why wouldn't you be using "bbb" as your key in that case
or do you reference it by both key and value
What's your use case here
 
theres no reason for me doing this except for a pre-interview question at a job i applied for lol
 
In the case where you need both, it would be VASTLY more efficient to just keep two maps, in the "real world"
If you care about the value, then the value should be your key
 
ah youre right i mean
i never thought about it but yeah essentially its just a reverse map so i could have a class host a reversed hash
is that what youre essentially getting at?
 
Ummmm no
If this isn't a real world scenario, then meh... do whatever
if you're really trying to maintain a set of K,V pairs by value, then something has gone radically wrong in your data modelling
 
11:13 PM
lol for sure i agree that this isnt a real world case
but this is literlly right in front of me from a job interview question
 
Well, you can do it 2 ways: the way you mentioned, but the problem with that is that you're expecting there to be only 1 unique instance of that value
which isn't enforced in a map
ie:
map.put("Name", "Tom")
map.put("Nickname", "Tom")
will work, but it's very cumbersome
you're better off holding two maps
 
right
 
Map<K,V> and Map <V,K>, and updating them both
That will take more memory, but be way more efficient
I think your code up there will break btw because you can't modify entrySet while iterating it
ie: it'll throw IllegalModificationException or something
 
has anyone here used HTMLUnit
i have a question about using proxies with it
 
Nope. I don't think people still use HTML.
 
11:19 PM
what do you mean by that :P
 
Sarcasm is "a sharp, bitter, or cutting expression or remark; a bitter gibe or taunt." Sarcasm may employ ambivalence, although sarcasm is not necessarily ironic. "The distinctive quality of sarcasm is present in the spoken word and manifested chiefly by vocal inflections". The sarcastic content of a statement will be dependent upon the context in which it appears. Origin of the term The word comes from the Greek σαρκασμός (sarkasmos) which is taken from σαρκάζειν meaning "to tear flesh, bite the lip in rage, sneer". It is first recorded in English in 1579, in an annotation to The Sh...
I apologise. I'm not supposed to be sarcastic anymore
 
lol, so you're a typical SO nazi
 
but sometimes it slips out
 
Yeah ok
 
Nah, I'm just a smartass
 
11:21 PM
lol
 
htmlunit has a proxyconfig that you can pass to the WebClient
 
can there be multiple WebClient windows?
 
windows?! htmlunit doesn't use windows at all, it's entirely non-gui
 
err, multiple WebClient instances
 
You can use a different proxyconfig with each WebClient
 
11:24 PM
:) just what i was wondering, thanks
 
btw: I've never seen htmlunit before 10 minutes ago. I got all those answers by googling "using htmlunit with proxies"
and reading the results...
 
well consider that payback for your smartass initial response
 
now THAT is a typical SO response
 
im lazy
 
Yeah, and it means you just burned your goodwill question here
:)
 
11:25 PM
so you are a nazi
I called it from the start
 
Only for lazy people
 
you have probably done the same thing before
 
Yeah probably. I'm old and cranky
and have no patience for sloth
so go and get the hell off my lawn
 
yes sir
bye
 
Oh Kylar
one thing
my code does work
but is it bad code essentially?
what is the correct way to iterate through a HashMap
and why cant i just iterate for (int i = 0; i < someValue; i++) and then just change the index like i can in C#?
the joys of cross platform coding lol
 
11:35 PM
index?
You're thinking of a list, not a map
a HashMap isn't a list
 
its a hash set
hash buckets
that hashes keys to a bucket, makes indexing faster
 
Yes, I'm familiar with that. How do you know the new key will hash to the same bucket?
 
ah i guess the issue is that you have to hash every time you go to view a record
 
semantically speaking, Maps are not ordered
and the hash buckets are sparsely allocated, so indexing them has no real meaning
 
that...yeah thats true, so iterating would not always help
 
11:38 PM
That's why an iterator iterates the keys in no particular order
 
I see
and the two map idea you had, how would that work?
 
in Java, only a List is ordered
other Collection implementations do not have order guarantees
Mmm 1 sec
 
kk
thx so much for ur help btw, im just starting out in Java
this is super helpful
 
Something like that. I haven't tested it, so YMMV
 
gotcha
btw this may be a silly question
but why doesnt public class BiMap<K, V> extends HashMap<V, K> (changing the orders of K & V) work?
 
11:47 PM
?
does it matter
 
no
lol
just curious because it works the same way either way! lol
also
what does the @Override directive do as oppose to not putting it?
 
It's an annotation, so you don't have to put it, but if you're overriding something, the compiler will check to make sure that you're actually overriding something and that it has the same method signature
so if the method signature changes, the compiler will tell you that your subclass is wrong
 
ah i see, so its to ensure overriding actually occurs
what about the final keyword?
i wish i could upvote in chat lol
 
you can * in chat
the final keyword enforces that no other classes can extend that class or method
unless it's a variable, in which case final means that it can only be assigned one time
 
so if your method takes in a final variable, in your method, you can only assign to it once?
 
11:59 PM
no
if your method is like this:
public void addThis(final int operand){
myvalue += operand;
}
for instance
 

« first day (1355 days earlier)      last day (3572 days later) »