Monday, April 19, 2010

Parse File Using Scanner - Java Implementation

Code snippet to parse a file using java.util.Scanner class.





Usage: Call the tokenizeUsingScanner method and pass it the File object and the delimiter for the file.
Note: The pipe symbol has special meaning in a regex -- so you need to escape it.

Tuesday, April 13, 2010

List all files in a folder - Java Implementation

A code snippet that recursively reads all the files in a folder and put them in a list




Usage:
Call the readFolder method and pass it the absolute folder path as a string.

Sunday, April 4, 2010

Fibonacci Number Series - Java Implementation

Posting a code snippet to generate a list of fibonacci numbers:



Usage:
Pass the number of fibonacci numbers you want to generate as a parameter
Returns a list of fibonacci numbers