Welcome To Snipplr


Everyone's Recent Java Snippets



1 ... 4 5 6 7 8 ... 13
A much better implementation of the parameterized and randomized CrabWorld
0 1341 posted 15 years ago by joswald
I had a subtle mistake in my code that was causing the exception. The corrected source code is below:
0 1101 posted 15 years ago by joswald
Code Snippet of showing dialog and toast in Android application.
0 1226 posted 15 years ago by rso
Factory for ObjectContainer for local db4o database
0 1114 posted 15 years ago by dogrizz
Does the same as `System.arraycopy(source, copyFrom ,target, copyTo, length)` but without worrying about invalid input. Example for an array of characters.
0 1115 posted 15 years ago by Voil
0 1421 posted 15 years ago by hariharank12
0 1328 posted 15 years ago by evandrix
0 1388 posted 15 years ago by noklpopl
Ever got tired of writing System.out.print(); all the time when testing, well, to avoid this, just create a helper method that will narrow it down to print();
0 1371 posted 15 years ago by visudex
This snippet will allow you to read user's input when they write in the console. This method uses the Scanner class, which is my favorite way of doing instead of using the Buffered Reader, with the Scanner, you can also read from a file.
0 1574 posted 15 years ago by visudex
This snippet will allow you to capture your screen in Java and saves the image as a PNG
0 1441 posted 15 years ago by visudex
Note that there is limited support for _CSS_ in Swing components which render HTML text. This example employs `padding`, `margin` and `font-size`. The full list of supported properties (and their limitations) are in the [Javadoc][1] [1] ht...
0 1690 posted 15 years ago by cruelfate
0 1432 posted 15 years ago by marti1125
A simple way to get the enum indicated by its ordinal value.
0 1705 posted 15 years ago by studioevoque
0 1192 posted 15 years ago by sinisterdeath
0 1374 posted 15 years ago by studioevoque
0 1456 posted 15 years ago by studioevoque
I wrote this for an enterprise level event logging cluster that has more traffic than Oprah. Has worked great for years of uptime... wish java had a decent bz2 implementation though.
2 2041 posted 15 years ago by kubaitis
Great for just about any kind of key/value in-memory caching... scales up to the limitations of the JVM, so it's about as good as it gets without clustering.
1 2318 posted 15 years ago by kubaitis
A "quick and dirty" way to delete a directory. For more cleaner implementation, see http://www.google.com/codesearch/p?hl=en#SS2by_AKaLs/src/org/apache/commons/io/FileUtils.java&q=cleanDirectory&l=972
0 1357 posted 15 years ago by studioevoque
0 1036 posted 15 years ago by bluestan
0 1064 posted 15 years ago by peceps
An [example][id]. Then, **anywhere** else in the doc, define the link: [id]: http://example.com/ "Title"
1 2260 posted 15 years ago by dankauffman
0 1235 posted 15 years ago by trusktr
The AppDriver for my employee payroll app.
0 1189 posted 15 years ago by trusktr
1 ... 4 5 6 7 8 ... 13