ZeServeur

The knowledge acquired through experience, everything else is just information ...

Displaying items in Java

computing_occurs

Since long, I know there is buffered flows when reading or writing that ... yes, but the question I often asked is "how much? What is the order of magnitude? ".

So I made a quick benchmark for, measures of that performance gain ... and it boggles the mind! I get the factors of 22 in reading and 35 in writing!

continue reading ...

cleanup Fact: a large application developed and maintained by several people, we ended up having a lot of dead code ...

One solution is to use the clean up of Eclipse, one arrives to remove some unused attributes ... but it does not go much further.

The idea would be much more radical: a tool to pass on all the code.

Fortunately (again), Eclipse just save your life :)

  1. Let's start by downloading Eclipse Core Tools: http://www.eclipse.org/eclipse/platform-core/updates/
  2. Select Project / package / class on which to pass the tool
  3. Via the shortcut menu, click Find Unreferenced Members. The search result is displayed in the Search View
  4. Get the ax ...

By cons, beware: it is possible that some classes appear to be unused when they are called by an extension point!

images I've always wondered how to, in an app "command line" Java, hide his password (eg ssh).

The solution comes with the JDK 6 and the class Console which allows (among others) to retrieve an entry without displaying what went ...

Here is a quick snippet putting into practice this class:

Import java.io.Console;
  1. (public class TestConsole
  2. main ( String [ ] args ) { public static void main (String [] args) (
  3. ( ) ; Console lConsole = System. Console ();
  4. . print ( "Username: " ) ; System. Out. Print ("Username:");
  5. ( ) ; String username = lConsole. ReadLine ();
  6. . print ( "Password: " ) ; System. Out. Print ("Password:");
  7. String ( lConsole. readPassword ( ) ) ; String password = new String (lConsole. readPassword ());
  8. . println ( "Username: " + username ) ; System. Out. System.out.println ("Username:" username +);
  9. . println ( "Password: " + password ) ; System. Out. System.out.println ("Password:" + password);
  10. )
  11. )

Warning: System.console() may return null (it depends on the platform) ... especially with the Eclipse console ...

What a tragedy ... how to make a series of tests under JUnit4 when apparently it no longer has TestSuite?!

continue reading ...

For those looking for cool icons, look here :

... And more is licensed under Creative Commons Attribution 2.5 License .