« first day (1425 days earlier)      last day (3509 days later) » 

12:16 AM
I'm BACK!
 
12:28 AM
@Kylar Yo
 
 
1 hour later…
1:57 AM
i was the guy who answered that @kiheru
 
 
5 hours later…
6:48 AM
@Unihedron was there another too? I was thinking about this: stackoverflow.com/questions/25821678/…
 
13 hours ago, by Unihedron
@ItachiUchiha Even if s1==s2 evaluates first, you'll still want to keep them in brackets.
13 hours ago, by Unihedron
yes, it evaluates to new StringBuffer(s1.equals(s2)).append(" ").append(s1).toString() == s2
 
It's a quite interesting case. + and == are operators where people get the precedence usually intuitively right, but even with those mistakes happen
I definitely prefer a slight overuse of brackets too. They don't clutter the code - they made it more explicit
 
@kih
-5
Q: Strings subtle differences In Java

Aamirpublic class StringTest { public static void main(String[] args) { String s1 = "java"; String s2 = "ja" + "va"; String s3 = "ja"; String s4 = s3 + "va"; System.out.println(s1 == s2); System.out.println(s1 == s4); } } First System.out.pr...

 
 
7:04 AM
Ah, ok. That one is actually duplicate as there's no issue with operator precedence (and the answer to the "how do I compare strings in java?" question does discuss the interning too)
I'm not sure how much the spec limits the optimizations the implementation may have. The compiler is fairly dumb, but one that did even a bit more work, could deduce that s4 too is "java" (actually, a good optimizing compiler would be able to eliminate all the strings)
 
 
1 hour later…
8:35 AM
morning
 
 
2 hours later…
10:06 AM
0
Q: When not to throw exceptions in java

fahdijbeliI want to know why we shouldn't throw an exception in : toString():toString() should be reliably used, independently of the state of the object. In particular error reporting and logging will use that method equals() and hashCode() : if your code in these methods can generate exceptions, you m...

 
10:30 AM
That has the problem as someone already said in the comments: each of the points is already an explanation.
I don't know if it's possible to rephrase it to so that you'd clarify what you in particular do not understand about them (and then too, it should be multiple questions, since, as a question should have only one question)
(As a side note, I don't particularly agree about static initializers being evil. They can be abused, but there are situations where they are better than any other design)
 
@fahdijbeli You probably need to describe more on what you actually meant.
 
 
2 hours later…
12:44 PM
Good morning, Java!
 
12:59 PM
morning
anyone active?
 
Hi @neowinian, welcome!
 
hello @Michael I need help, do u have second?
 
@neowinian What is your problem?
 
Hallo
Can someone give me a simple explanation of polymorphism, inheritance and what super() does?
I used all of them but I can't really explain them simply/
 
1:17 PM
@Michael I am playing around with joda date time and Periods. I want to subtract certain certain date with a time period. if I win achievement 05.05 ( let's assume it can be won once per month), next achievement can be won on 06.05. But I would like to be able to win it on 06.01
 
So, you can win an achievement once per month.
 
yes
but if I won it on 05.05 I don't want to wait whole month to pass, instead I want to be able to won it on the 1st of following month
 
I don't know if Periods are what you need in this situation.
You just need to write logic that says, "Player X got an achievement in month Y".
 
1:35 PM
Hello Michael !
ssup ?
 
Hey @ItachiUchiha!
 
We're writing a book!
Hiya @Michael and @ItachiUchiha!
 
Hey @Unihedron.
@Unihedron Nice.
 
2:06 PM
Hi guys
new to sof chat :)
 
@Hakuna welcome to SO Chat
 
Welcome @HakunaMatata :P
 
thanks Itachi
gonna be regular on so chat hereafter
Thanks unihedron
Where are you guys from ?
 
lol, you'd be surprised at how the "regulars" here aren't really regular.
Earth, Alpha Centauri
 
:D
r u regular ?
 
2:17 PM
No, I'm paid to fill seats, but if you have a Java question, feel free to ping me.
 
sure
which country are you from ?
 
What's a country? o_O
Gimme the codez! Its for client! ASAP! Kill it with fire! Halp! stackoverflow.com/q/25890898/3622940
@ita ^
 
It got -4
 
And 3 pending close votes
 
 
2 hours later…
4:40 PM
any xpath people here?
 
5:34 PM
psychopath?
 
Holy cow! The room is active!
 
@BenBeri not
Hiya!
 
hello!
 
Wow!
 
is it possible to do xpath from a nodelist?
 
5:39 PM
An actual [almost] conversation might be starting! Let's all sit quietly and watch!
 
i have an xml with 2 bookingitems. i need to loop through these elemets and create java objects from them.
i can easily turn the bookingitem elemets into a nodelist using xpath, but for the bookingItem's sub-elements, can I easily get a handle on those?
i know I can use node.getChildrn() but thats a slow method
 
No experience with xPath, maybe someone else knows though.
 
ah
maybe i could ise a different technology
know any good ones?
I have an xml, need to turn it into a deep java object
 
Oh? Like Resource.fromXML()?
 
mm, dont get you
 
5:46 PM
Me neither - what do you mean by turning an xml into a deep java object?
 
i have an application that takes xml as input, and turns the xml into an existing java object
some of the member variables of my object are objects themselves
 
And what's the "existing java object"? new Object()?
 
an object i cant change
 
Eh all
 
its from an eternal jar
2
 
5:52 PM
So really, you're reading in xml from a stream and deserializing it?
 
yes
 
Guys
 
This is an XY Problem. <-- read that and come back and tell me more about what you actually need.
 
In computer science, A* (pronounced "A star" ( listen)) is a computer algorithm that is widely used in pathfinding and graph traversal, the process of plotting an efficiently traversable path between points, called nodes. Noted for its performance and accuracy, it enjoys widespread use. However, in practical travel-routing systems, it is generally outperformed by algorithms which can pre-process the graph to attain better performance, although other work has found A* to be superior to other approaches. Peter Hart, Nils Nilsson and Bertram Raphael of Stanford Research Institute (now SRI International...
 
@BenBeri what?
 
5:53 PM
How can I know what does each character means in the algorithm math?
go to #propetries
 
@Unihedron LOL. funny link
 
????
 
How can I know what does L, P mean?
eg L(P)
 
@BenBeri erm... maths?
 
Ooo an Eternal Jar
That's from Zelda, right?
 
5:55 PM
Read the article? "where L is a function that denotes the length of a path, ..."
 
@kiheru (applauses the insightful read)
 
6:08 PM
Guys
I wanted to ask
Is it bad saving a lot of byte arrays into a file using ObjectOutputStream? It reduces the size of the original file
 
I don't understand your question
What's in the byte arrays?
What do you mean "reduces the size of the file"
You're asking questions that we can't answer without more background
 
@BenBeri It's not bad and it doesn't reduce the file size and there's no correlation.
Likely you're just doing it wrong.
 
Well I took a file, spilt it into arrays, each array has 1kb of data. Added the length count into the OOS, and then all byte arrays and saved the file
reduced from 104mb to iirc 9km
 
That's like a 1100% reduction
 
& When I turn it back to original file, I get the same size
 
6:15 PM
you did something wrong
are you zipping it?
you took a 104mb file and read it into 104,000 arrays of 1k each?
in memory?
 
Sec ill give you the source
let me know wheres my mistake
ignroe first line with the server.run
 
Are we looking at writeNew?
 
just by looking at the file names, not code... .dat -> .tar.gz - sounds like compression
 
nah dw about it, i have made a few gzip attemtps before
it doesn't compress i thin
I'll check though
@Kylar Yeah writenew
 
You're not compressing anything
 
6:20 PM
o.writeInt(len);
 
However guys, when I try to load the file (after reading it from my new write) the game client will not be able to load it
 
Yeah
 
it will say error loading, but the file size is the same
 
cause you're not actually writing back the same stuff
 
does not look like you're writing the contents,
 
6:20 PM
Not sure why
 
OK I'm annotating your code
Give me 5 minutes
 
alright man
 
and I'll re-paste it
 
I think my problem that it doesn't load is with reading method
actually i have no idea lol
 
no, it's in the write. You do not write the file contents (waiting for the annotated version, which will likely have the explanation)
 
6:26 PM
@kiheru I did it like this by following this answer stackoverflow.com/a/921408/3123545
But its probably not working, because OOS writing is different and I don't include the same parameters , just the array
 
There's a series of problems, but I'm doing 2 things: annotating your code to explain what it's actually doing, and giving you a new example of one that does the right thing.
 
Alright thanks buddy
Also in the loading method, I didn't use arrayCopy because i always got out of memory exceptions lol
 
Yeah you're trying to load too much into memory
but I'll fix that too
 
Will the file size still be reduced by a lot?
 
No, it will be longer by 4 bytes
because you're reading and writing the same thing
and then adding a 4 byte int
if you want to compress the file
that's another thing
 
6:41 PM
Ah i see
 
For file size reduction, take a look at the compressing file streams (Inflater*Stream, Deflater*Stream, GZIP*Stream, ZIP*Stream)
 
Whats the best compression library for java?
 
Just use zip if you're doing compression, it's the simplest
"best" has a lot of meanings
 
best in what sense? fastest or highest compression ratio
 
By best, i mean the highest reduce
gzip reduces more than zip or?
 
6:47 PM
the lzma has likely the highest compression ratio, for commonly used formats. That's for generic data
Using what the standard library supports, is definitely easier though. So consider whether the higher comression is worth the external dependency
 
Stop!
Let's close it!
-1
Q: Server keeps crashing while running Fjord Engineering Web Framework v2.3

Tammy I am running Fjord Engineering Web Framework v2.3. Sometimes my server dies for no reason. Does anyone know what might be the cause of this?

 
@BenBeri if your goal is just to compress the stuff you're reading, I'll write something for that.
There's the annotated write method with why it's not working the way you think it should
I'm writing you a new zip/unzip method right now.
 
10x kiheru :)
 
Alright thanks man ill take a look
I see
 
7:02 PM
Almost done the zip one
2 mins
Grrr I need to upgrade the drives on this machine
 
Is Zip4J any good?
 
they're so slow
@BenBeri does that explanation make sense?
 
yeh
 
Ok
It's a bit tricky knowing what OutputStream to use sometimes
 
7:14 PM
That would shorten the close vote queue, but I dread what the reopen queue would look like in a moment
 
The close votes queue just went up from 9.9k to 11.9k lately.
 
I didn't take a look at it for about a half a year, but I have a vague memory that it was a lot longer in mid winter
 
Yeah, like 130k.
 
@BenBeri There's a quick example of zip read/write. I made a few comments with some more best practices so that you can get a bit better feel for what to do
especially when writing byte arrays, you need to always send a length
otherwise you'll end up writing garbage in the last loop
@Unihedron let's steal most of the rules from #javascript
They have a pretty good handle on what to do and not to do
 
^^^^
 
7:22 PM
;)
 
It's three in the morning. :P
 
back
@Kylar Thanks man
The best I could come up with is, GZIPOutputStream, from 104mb to 88mb :/
 
7:37 PM
That's not bad, 20%
 
Probably the nature of your data. If it contains stuff that is already compressed (such as almost any image format), it won't compress well
 
Remember, compression isn't the be all and end all. It's not good for binary data
in rare cases it can even increase the size
 
Hi all )
So I made a layout
with a west panel and am east panel
east panel got a button
and west panel should display my drawing
now the thing is when I try to click on my button to make the drawing appear on my west panel it doesn't show up
but when I just add the drawing on the panel without the button it shows up
why?
 
You're probably not revalidating and repainting
if you re-size the frame does it suddenly appear
0p3ns3same
Whoops ;)
 
Anyone here good with Netty?
 
7:45 PM
@BenBeri Yes
 
@Kylar I really don't get their guide, I made an handler, I have Object msg in my channelRead method, but It's always instance of UnpooledUnsafeDirectByteBuf when I use telnet
 
So you're just starting from the very beginning?
iE: no netty experience?
What are you trying to do?
 
I am trying to understand how to make a server which is able to receive data, and send data to whatever client I want
With netty, already done so with java socket
First NIO experience now
 
How are you going to receive the data? http? telnet? raw socket?
 
telnet to test atm, ill use a socket client later
 
7:50 PM
Well, telnet connects to a raw socket...
;)
post the code you've written
I have the netty jars
 
@Kylar it was revalidate
 
@Sabಠ_ಠ ;)
 
but i dun understand why revalidate though
 
When you make a manual change to a component, it doesn't necessarily know that you've done that
 
can u explain why i need to revalidate my object and not my panel
 
7:55 PM
so you have to tell the system to refresh it's view
 
what about repaint?
 
you should never call that
the system calls it
 
aha
but why repaint doesn't work
 
That's more complicated, it has to do with the system only painting things that have changed
 
aahhj
 
7:57 PM
That's a good read
it'll explain a lot of how the painting system works for swing and AWT components
 
Thanks :)
 
especially the differences between system triggered painting and user or application painting
 
Smooth
quick question about internships now :P
 
ie: if you drag a window across your app, the system will call all the right things
Sure, hit me
 
^
that's what was hapening when revalidate was not used.
when I maximized it appeared
back to the internships
I have 0 experience
is it possible to get intern?
I'm interviewing at amazon on saturday
:/
problem is my knowledge is kind of limited and I'm pretty new to Java
 
8:00 PM
How'd you get an interview
if you have no knowledge or experience
 
it's a university thing
 
are you in CS
2nd or 3rd year?
 
you had to solve 3 programming problems to apply and get an invitation
first year cs and maths
there will be several companies where we can interview, i'm going for all of them
I know my knowledge is not a lot but just the idea of getting interviewed by amazon is fine by me
however, I'm not sure how to go about it.
 
Did you read the netty telnet examples already?
NettyTelnetServer
 
8:20 PM
yes i did
 
When you run the examples, can you receive the data
ie: does TelnetServer run properly?
 
It gives me some random line when i write something
in the telnet
like random lines _ _ _
-- etc
 
Run the server in the debugger and set a breakpoint in TelnetServerHandler.channelReid0
Read0 that is
;)
 
I think I should have an networking background before learning netty
as in learn the protocols, how they work etc
 
That's a good idea
Knowledge is power!
The more you know!
 
8:33 PM
lol
got a question
If I have only one thread
Is there a reason to use ThreadPoolExecutor just for one thread?
My mate keeps telling me to use Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(.....); even if I have a single thread (besides AWT)
 
8:46 PM
That's a fine way for timed execution. java.util.Timer can do almost the same thing (it can't do Futures), but the executor service is a higher level API. I'd use that unless you have a good reason not to
It's not a thread pool anyway, but single threaded like the name says (same as the Timer)
 
It's an easy way to encapsulate using any other threads (other than the main and event thread)
 
in both cases you need to care about thread safety: the timed execution happens in a thread that is separate from the EDT and your other thread (you said you have one besides the EDT)
 
There is always a main thread, plus the EDT
plus any others :/
 
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new GUI();
        }
     });
    // Hereafter, all user action happens in the EDT, unless new threads are requested
}
the system will create a ton of threads, but there won't be a main thread for the user
 
Ell
9:35 PM
Hi all
 
hi @Ell
 
Ell
I'm having real trouble with the JNI :(
My CallVoidMethodA isn't working, and I can't seem to get any reasonable debugging info
 
I'm not really of help with JNI. I basically have just tried how it works a long time ago, and after that managed to avoid it
 
Ell
Ahh right okay
 
 
2 hours later…
11:33 PM
Hello
 

« first day (1425 days earlier)      last day (3509 days later) »