« first day (1520 days earlier)      last day (3415 days later) » 

10:08 AM
@George02 What do you mean?
Oh, they left.
 
fge
Moo
 
Heyyyyyy
 
10:36 AM
@Uni I have written this lambda expression to filter all persons with gender = male & print it's first & last name:
List<Person> males = persons.stream().filter(p-> (p.getGender() == Person.SEX.MALE)).map(p-> p.getFirstName()+" "+p.getLastName()).forEach(firstName->System.out.println(firstName));
 
I want to make a java application that runs on a server continuously and it's has to be refreshed(updated) after each period of time - could someone suggest the scenario plz?
 
@Mr.777 Do .forEach(System.out::println) instead of what you did at the end.
 
fge
@Mr.777 the last can be shortened to System.out::println
 
too slow, @fge :p
 
@Unihedro Yes but there is compile time error
 
10:38 AM
@Mr.777 show me?
 
Error:(50, 147) java: incompatible types: void cannot be converted to java.util.List<com.java8.lambda.Person>
 
fge
Ah yeah
Normal
 
???
 
And I can't see any void as per my understanding
 
fge
Remove the List<Person> males =
@Mr.777 .forEach() returns nothing
 
10:39 AM
Oh.
 
Awwww :P
 
Maybe you want .peek().collect(Collectors.toList());
where peek holds whatever you want to do to each object
 
fge
@Unihedro that won't work either
You can't .peek() from void
Anyway, I have work for @Mr.777 so if you could please avoid to disturb him :p
 
@Unihedro Interesting
:P
 
@fge No worries, I gotta head out to a function tonight anyways, so I can't even stay in here
 
10:42 AM
I want to make a java application that runs on a server continuously and it's has to be refreshed(updated) after each period of time - could someone suggest the scenario plz?
 
@JavaFan um... good luck
you'll need it
 
@Unihedro I think I need to make a thread am I true?
 
@JavaFan It depends, synchronous single threaded applications can do time detection well too.
 
okay
 
fge
@Unihedro head out to a... Function?
 
10:44 AM
But for the purpose of good code you must exercise and excel in multithreading to achieve your purpose in the optimal way.
@fge ?
 
fge
@Unihedro this is what you said
 
*was
Where?
 
it depends on what?
 
fge
I'll just star it, you'll see
 
4 mins ago, by Unihedro
@fge No worries, I gotta head out to a function tonight anyways, so I can't even stay in here
 
10:46 AM
Are there ways other than threads?
 
Oh... function as in event
English... Difficult.
 
fge
@JavaFan what do you mean by "updated"?
 
look , the suggested java software has to get new hyperlinks from web pages and insert them in the database
 
fge
@Unihedro revealing typo, that
 
So what is the better way for me thread or methods?
 
fge
10:53 AM
@JavaFan no way to tell at the moment, you don't even tell how those new links are going to get fetched
But if they are fetched at regular periods then use a ScheduledExecutorService
And if it's a server app, don't forget logging
Use slf4j for that
 
they are to be fetched by jsoup library
slf4j?
 
fge
Simple Logging Facade 4 (For) Java
And choose your poison
logback, log4j, log4j2, java.util.logging...
 
"Choose your poison"... That's about what I think about logging, powerful but vital
 
Should I work with apache also?
 
Morning
 
fge
11:07 AM
@JavaFan why? You only fetch web pages, right? You don't serve them?
 
yes I only have to fetch web pages and insert them into database periodically
 
@Gemtastic Morning
 
What's up?
 
chess tourney before I have to head out
 
I see
I wish I could play chess well enough :P
 
11:10 AM
:P
 
Mostly logging in to keep my consecutive visits up
 
lol
 
Stuff happens when you're a guest
 
:P
 
Once you get the badges, the entire cont is pointless
Same with helpful flags; They aren't public.
> visits
member for 7 months
visited 219 days, 206 consecutive
seen 3 mins ago
stats
profile views 2,067
helpful flags 7285
 
11:12 AM
Yeah, but I'm trying for the badges still so...
My record got broken when my internet went down :(
 
:O
inb4 it breaks again
 
well, now I'm on the in-laws internet
 
Wow ;)
 
I hope you use a VPN so the connection is secure.
 
why would I need that?
It's not like I'm using it without their permission
 
11:14 AM
Hm... You probably won't need it though.
<-- uses the most secure connection standards everywhere
 
This is sweden; internet is very good. That our internet went down was a huge outrage
 
:O
mandatory commitstrip
 
XD
I'm gonna have to get into that for the compensation, I didn't get a discount on the bill this month as promised >_<
 
Heading out now; See you all in another few months or so!
 
take care Uni
 
11:22 AM
@Unihedro What?
Really?
@Uni I have flagged your comment
:P
5 mins ago, by Unihedro
Heading out now; See you all in another few months or so!
^ Not acceptable
Well, not "Heading out now" part but the other half ;)
 
@Mr.777 why ?
 
@TGMCians Coz it's not allowed for him to leave the room for months :D
 
ah someone flagged his posted pic also...*weird*
 
Yeah I mistakenly hit that :P
 
ah pls don't do . thanks :)
 
11:32 AM
There is something call MISTAKE, that just happens :P
 
12:06 PM
If someone experimented with JMH could tell me it my benchmark is fine
4
A: How to convert an array T[] to V[] when V is an attribute object in T

ZouZouIf you are using java-8, you can use the map operation on Stream: V[] arr = Arrays.stream(arrayOfTypeT).map(t -> t.v).toArray(V[]::new); or even better (if good encapsulation) V[] arr = Arrays.stream(arrayOfTypeT).map(T::getV).toArray(V[]::new); So here's the benchmark (note that I'm not a...

 
fge
@ZouZou no idea; I tried and used jmh, but failed
Also, isn't there an array collector?
Hmmno
 
@fge I don't know, I always use the constructor reference
 
fge
Well, I'll star this post, I have NEVER managed to run jmh at the command line before!
 
12:37 PM
@TGMCians TGM!!! YOU'RE ALIVE!!!
@ZouZou Maybe you could create a new array of V[] and then copy the elements over
@Mr.777 Time is relative, a few months for me is only a few hours for you
 
@Unihedro :P
 
@Unihedro yes someone suspended me from tavern only for 30 mins.. without any reason.. anyways how are you ?
 
@TGMCians I saw, mods casting mod flags are automatically approved
(I'm always watching)
 
:)
 
Guys git pull upstream vs git pull --rebase
Whats the difference?
 
12:47 PM
@Mr.777 One pulls from upstream, ones' basically rebasing
 
can somebody help me answer this question?
0
Q: Query on java I/O byte stream class

overexchangeBelow is the program which created separate byte streams for reading from and writing into same file. import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class FileCopyNoBuffer{ public static void main(String[] args){ ...

 
fge
Aargh
File
pukes
 
:P
 
fge
@overexchange why 1.6? Can't you use 1.7?
0
A: Query on java I/O byte stream class

fge [...]for reading from and writing into same file. NEVER DO THAT. EVER. The results are unpredictable. If you want to modify the contents of a file, write the new contents into a new file and then atomically rename to the old -- after you have ensured that the new content was successfully w...

There, answered
 
+1 for the never do that ever
 
1:03 PM
@Unihedro We putted out a beta today, dalthow.com/share/launcher/launcher-download/… tought you might want to see it ;)
 
:O OMG
 
Buggy but functional :)
 
By chance, how do I register? It's stuck at 0%
Woot, now it's downloading
 
Registration can be found here dalthow.com/registration.php (there is a link in the launcher)
 
Awesome game!
 
1:13 PM
Haha thanks, wanna do some 3d game next, mabye a MMO
 
Can I ask a question?
 
Go ahead :)
 
Why is your logo design so... invisible?
 
wait wut!?
Its supposed to look like this i.imgur.com/YWbi7gW.png
 
// inverted colors user
 
1:16 PM
haha XD
 
in Tavern on the Meta on Meta Stack Exchange Chat, Dec 14 at 15:09, by Unihedro
stop using transparent backgrounds AND black lines, inverted color users really suffer
 
lmao
 
Or, you know, at least wrap the logo within a span because that's how it's supposed to work by CSS3
 
will do ^^
 
<span id="logo">Etaron</span>

#logo {
  color: inherit;
  background: url(pic to url);
}
 
fge
1:20 PM
Just out of curiosity
Does Windows support atomic moves?
 
1:33 PM
I don't think so... It depends on the file format?
 
I didn't do it!
 
@Alagaros Why can I jump in midair
 
Good morning, Java!
 
Morning, @Michael!
 
fge
Argh, I need another Windows test!
 
1:34 PM
Morning @Uni :)
 
fge
@Michael good morning milord, and thanks for graciously lending Oakbot to that unworthy room of mine
Can someone on Windows please try this for me: Files.readAttributes(pathToAnExistingFIle, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS)
Does it throw an exception?
 
@fge lol np
Not on Windows, sorry.
 
fge
@Michael don't be sorry, this is what I wanted to hear :p
And it means I have to fix a bug in java7-fs-base
 
I completed the final level and am now stuck, @Alagaros.
 
@fge What kind of bug?
 
fge
1:42 PM
@Michael I throw an UnsupportedOperationException when I see this option whereas I should ignore it
In all my current filesystems
 
Ah.
 
@Alagaros Also, completing Medium - Into Fire by touching the green dot doesn't advance me, the sound is played though.
 
@Michael @Unihedro @fge Greetings
 
Hey @Joe
 
fge
hums itself some tune of Jimi Hendrix, go figure
 
1:52 PM
@fge "pathToAnExistingFile"?
 
fge
@Unihedro meh, just Paths.get("somefilewhichexistsonyoursystem")
And you'll get a pathToAnExistingFile :p
Paths.get("") for instance
 
But... Do directories count?
 
fge
Yes they do
All fs objects have attributes
And all filesystems are required to support BasicFileAttributes
 
How horrible of me would it be to catch an IllegalAccessException and rethrow it as RuntimeException to avoid having declare it in the signature or handling it inline?
 
@SecondRikudo You should still document it though.
 
1:55 PM
^^ that.
 
Or at least wrap them: catch(IllegalAccessException ex) { throw new RuntimeException(ex); }
 
@SecondRikudo Not horrible.
If you know that an exception will never be thrown, or is very unlikely to be thrown, I would recommend doing that.
And do what @Uni said.
 
@Unihedro Document it how? What do I write?
 
// @SecondRikudo
/**
 * blah description here blah blah
 *
 * @throws RuntimeException
 *        When an {@link IllegalAccessException} is thrown (unlikely),
 *        a wrapped exception of this type will be rethrown.
 */
public static void methodThatLooksLikeNoExceptionWillBeThrown();
 
I see
 
fge
1:59 PM
Hmm, reflection, eh?
java.lang.invoke!
nudge
 
inb4 indy appreciation
 
How do I getMessage of the inner wrapper exception?
 
e.getCause().getMessage()
When you do new Exception(exception);, you're really just doing this:
/**
 * Constructs a new throwable with the specified cause and a detail
 * message of {@code (cause==null ? null : cause.toString())} (which
 * typically contains the class and detail message of {@code cause}).
 * This constructor is useful for throwables that are little more than
 * wrappers for other throwables (for example, {@link
 * java.security.PrivilegedActionException}).
 *
 * <p>The {@link #fillInStackTrace()} method is called to initialize
 * the stack trace data in the newly created throwable.
 
=javadoc Exception#Exception(Exception)
 
@Michael Exception(): Constructs a new exception with null as its detail message. The cause is not initialized, and may subsequently be initialized by a call to #initCause.
 
2:10 PM
=javadoc Exception#Exception(Throwable)
 
@Michael Exception(): Constructs a new exception with null as its detail message. The cause is not initialized, and may subsequently be initialized by a call to #initCause.
 
Ugh.
 
Constructors?
 
Are not working right, apparently. :/
 
Hmm, I wonder if there is a more elegant way of polling data.
 
2:18 PM
/**
 * The parse method is the main method for every command.
 *
 * It accepts an array of strings are arguments passed
 * directly from the CLI (sans the first argument) and
 * executes whatever the
 *
 * @param args Command line arguments
 * @throws Exception when things go royally wrong.
 */
public abstract void parse(String[] args) throws Exception;
I likey.
 
O-o
 
@Unihedro Everything should be handled internally, if they don't, shit really hit the fan
 
@Unihedro Yeah. It's called websockets. Which I can't get to work. :(
 
@Michael JCE is going to use Jetty for the websockets, since Apache's Websocket FR hasn't been accomplished yet (since 6 years ago...). Once I finish JCE with the poor man's websocket implementation, I'll rebuild a websocket module with Apache HTTP libraries.
'Cuz, you know, I can totally rebuild the Websockets myself using the Websockets specification from w3c.
It's going to break occasionally if I forget a check, but hey, it's totally worth it.
@SecondRikudo nods
 
There's Java websocket libraries out there, you know.
 
SJD
2:25 PM
Hello. I have a question.
 
I've been using Jetty for websockets, is java-websocket any better over that?
It looks appealing, though.
@SJD Hello, please go ahead and ask!
 
Not sure.
 
Well, since I have access to the Internet (no joke sherlock), lemme google for reviews!
 
SJD
I have for instance a ListView in javaFX and inside it I have a custom cell which contains a button. My question would be: besides my first ListView, I have another ListView (cart) and once I press the button from first ListView cell there should be added an element in the second ListView
 
Ok, 10/10 definitely switching
 
fge
2:27 PM
has learned a lot about BOM, aka U+FEFF
 
SJD
How can I manage to use the second ListView inside of my custom Cell?
 
@SJD Can't you keep references to both ListViews?
 
@SJD don't do that... but if you want to, do what uni says
 
And, you know, manipulate them correspondingly
 
You're breaking information hiding principle ;)
 
SJD
2:28 PM
@Vogel612 yeah I'm aware of that..
 
Otherwise, it will take a ridiculous amount of effort to get the ListView at runtime to modify, and it's not worth your trouble, nor the computation power.
Caching is good (most of the time), anyway. Plus you get something to blame when stuff goes wrong.
 
SJD
Ok, but what do you mean to "keep reference" to both?
How shall I understand that?
 
@Unihedro inb4 sibc
 
class MyClass {
  static ListView first, second; // not the best way to do it, but sure
  {
    // write after you create them
    first = /* ... */ null;
  }
}
 
private final ListView cart;

public ChooseView(ListView cart) {
   this.cart = cart;
}
 
SJD
2:30 PM
got it!
danke!
 
Good luck!
 
SJD
wow.. I missed one thing.
 
Oh?
 
SJD
events on my button!
I can't use first nor second ListView inside it's button action event
 
Why not?
 
SJD
2:32 PM
how? sending as param the ListView?
 
@SJD the references need to be effectively final
 
SJD
I see. good then:P thanks again for support guys!
 
@SJD Your event should be able to reference the fields within its scope right? You might have to deal with visibility and static-ness to get it visible within your event method.
 
eehhhmm. somebody know how I can specify a non resultbearing ScheduledFuture??
@Unihedro static shouldn't be required
 
@Vogel612 Hmm.
@Michael Yay Java-WebSocket is on Maven Central!
 
SJD
2:36 PM
@Vogel612 Unihedro is right. need static
 
@SJD then you're probably doing something... "wrong"
 
SJD
@Vogel612 why?
 
your ListView should be contained in a stateful class...
 
What if the class is not stateful?
 
SJD
Btw, it's a controller.
 
2:38 PM
@SJD Controllers should IMO be stateful, since they may contain different data depending on session..
but I am not a JavaFX guy... more of a JEE/JSF person.
@RequestScoped ftw.
 
Shutting down. See you later.
 
@Vog should we have a milestone for FR about commands?
learning to use GitHub
 
FR??
 
Feature request
Pham is still running, I'll reboot him soon
 
what exactly are you referring to there?
also.. why not?
 
2:45 PM
OakBot Online.
 
=javadoc immutablelist
 
@Michael com.google.common.collect.ImmutableList: A high-performance, immutable, random-access List implementation. Does not permit null elements. (1/4)
 
=javadoc ScheduledFuture#cancel()
 
@Vogel612 That method doesn't exist.
 
dammit...
=javadoc Future#cancel()
 
2:48 PM
@Vogel612 That method doesn't exist.
 
=javadoc Future#cancel()
 
@Vogel612 boolean cancel(boolean mayInterruptIfRunning): Attempts to cancel execution of this task. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started when cancel is called, this task should never run. If the task has already started, then the ...
mayInterruptIfRunning parameter determines whether the thread executing this task should be interrupted in an attempt to stop the task. (1/2)
 
get the inherited methods' javadoc from the given superclass if specified ;)
 
@Vogel612 That should have worked...
Yeah.
 
well the javadoc does not give any info on the ScheduledFuture javadoc directly. It just references back to Future...
 
2:53 PM
It should still be pulling the javadocs from the parent interface's methods though.
 
@Michael well it's your baby, I wouldn't know ;)
=javadoc Executors#newScheduledThreadPool(int)
 
@Vogel612 ScheduledExecutorService newScheduledThreadPool(int corePoolSize): Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.
 
fge
=javadoc TimeUnit#toMillis(long)
 
@fge long toMillis(long duration): Equivalent to #convert(long, TimeUnit) MILLISECONDS.convert(duration, this).
 
fge
This one is great:
=javadoc TimeUnit#sleep(long)
 
3:02 PM
@fge void sleep(long timeout): Performs a Thread#sleep(long, int) Thread.sleep using this time unit. This is a convenience method that converts time arguments into the form required by the Thread.sleep method.
 
fge
Thread.sleep() is obsolete ;)
 
well is it marked deprecated??
 
fge
TimeUnit.SECONDS.sleep(5L); --> better than Thread.sleep(5L * 1000) ;)
 
hmmm that's cool... but I'd say that is bordering to code-obfuscation...
 
fge
Really?
 
3:04 PM
Vog's Code Review roots are waking up...
 
fge
To me it's pretty obvious that you want to sleep 5 seconds
 
I wouldn't expect a TimeUnit to be able to sleep() ...
I'd rather see Thread.sleep(5, TimeUnit.SECONDS);
 
fge
If you don't recall at a glance that the argument to THread.sleep() is milliseconds, with this you have no problem understanding imho
 
but "there is no Thread.sleep()"
 
fge
@Vogel612 could be nice... But this method does not exist
Request to the OpenJDK devs? ;)
 
3:06 PM
TBH I don't use Thread.sleep anyways, so it's a non-issue for me..
and you could actually call Thread.sleep(TimeUnit.SECONDS.toMillis(5L)); anyways.
 
fge
No thanks, I'll keep using TimeUnit#sleep() ;)
 
understandable. It's rather nitpickish anyways...
nothing but Threads is sleeping, soooooo
anyways back to my Timer command..
 
Is it possible to effectively use method overload when invoking via reflection?
public class ListThings extends Command {
    public void parse(String[] args) throws Exception {
        try {
            Method method = this.getClass().getMethod(args[0]);
            if (args.length > 1) method.invoke(this, Arrays.copyOfRange(args, 1, args.length));
            else method.invoke(this);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException("Can't list " + args[0] + ", no such method");
        }
    }

    public void properties() {
        System.out.println("get properties invoked!");
When invoking with properties it works, when invoking with properties foo it fails with "wrong number of arguments"
 
getMethod will return the parameter-free implementation in both cases.
=javadoc Class#getMethod(String)
 
@Vogel612 Method getMethod(String name, Class[] parameterTypes): Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object. The name parameter is a String specifying the simple name of the desired method. The parameterTypes parameter is an array of Class objects that identify the method's formal parameter types, ...
in declared order. If parameterTypes is null, it is treated as if it were an empty array. (1/6)
 
3:19 PM
you need to specify the parameterTypes if you want to grab the signature with Object...
if (args.length > 1) method = this.getClass().getMethod(args[0], {Object.class}); //carry on
 
@Vogel612 Here's what I want: I want that regardless of what other parameters are passed to this specific method, it should always call the no parameters one.
 
why don't you just call the method without passing additional parameters to it?
the if-else is completely superfluous, if you don't want to do something with arguments other than the first.
 
3:37 PM
@Vogel612 Because for methods other than properties I will want to pass arguments.
 
that won't work like this...
not the way you're doing it now...
since you will keep grabbing the wrong methods when you got overloads.
 
I think I'll just have all of the methods accept String[] args and just ignore it inside the method.
 
yaaay Duck-typing....
 
:P
Because it's either accept String[] args, or accept nothing at all
 
fge
0
A: How to sort a list of objects

fgeUse TimeUnit to replace your Unit enum. Your Term class could therefore have a .toMillis() method which is very simple: public final long toMillis() { return timeUnit.toMillis(value); } You can then just Long.compare(o1.toMillis(), o2.toMillis()) in your Comparator. Other solutions: if...

 
3:44 PM
Interesting, now I get argument type mismatch:
public void parse(String[] args) throws Exception {
    try {
        Method method = this.getClass().getMethod(args[0], String[].class);
        if (args.length > 1) method.invoke(this, Arrays.copyOfRange(args, 1, args.length));
        else method.invoke(this, new String[]{});
    } catch (NoSuchMethodException e) {
        throw new RuntimeException("Can't list " + args[0] + ", no such method");
    }
}
public void properties(String[] args) {
    System.out.println("get properties invoked!");
 
where?
 
getMethod expects a Class[]
and not a Class.
 
@Vogel612 No, it's a variadic
=javadoc java.lang.Class#getMethod
 
@SecondRikudo I don't know that command. o_O
 
=javadoc java.lang.Class#getMethod
 
3:46 PM
@SecondRikudo Method getMethod(String name, Class[] parameterTypes): Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object. The name parameter is a String specifying the simple name of the desired method. The parameterTypes parameter is an array of Class objects that identify the method's formal parameter types, ...
 
doesn't react to edits yet.
 
in declared order. If parameterTypes is null, it is treated as if it were an empty array. (1/6)
 
Huh, odd
 
fge
=javadoc MethodHandles.Lookup#findVirtual(*)
 
@fge Sorry, I never heard of that class. :(
 
fge
3:47 PM
Oakbot, you dum
 
Method method = this.getClass().getMethod(args[0], new Class[]{String[].class});
Still the same error
 
fge
=javadoc java.lang.invoke.MethodHandles.Lookup#findVirtual(*)
 
@fge MethodHandle findVirtual(Class refc, String name, MethodType type): Produces a method handle for a virtual method. The type of the method handle will be that of the method, with the receiver type (usually refc) prepended. The method and all its argument types must be accessible to the lookup object. (1/6)
 
fge
Aah
@SecondRikudo ^^^^
 
wtf is wrong with that link? :|
 
3:51 PM
> We're sorry, the page you requested was not found.


We have recorded this error (404) to help us fix the problem.
You may wish to try again using one of the tools below.

Back to Previous Page
Site Map
Product Index
Software Download Index
To search for your page, try our Search function.
 
fge
@Michael links to inner classes' methods are broken
 
@fge How does that help me?
 
fge
@SecondRikudo that's the Java 7+ way of invoking methods
Learn to use java.lang.invoke instead of java.lang.reflect
 
I'm pretty sure I don't have Java7+ available :|
 
fge
Uh?
Hey, this is 2014
Are you sure?
 
3:54 PM
@fge Our stack uses Java 6, and I'm relying on packages from our stack
 
fge
Ahwell, OK then
 
There's a process of getting it up to speed with 8, but until then...
 
:o
 

« first day (1520 days earlier)      last day (3415 days later) »