Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Java challenge!



Hi all,

I have been given the following challenge:
-------------------------------------------------------------------------
Write a Base64 encoder/decoder in Java for me in two ways:

1) Using an existing Base64 library routine
2) From scratch, using string/character/byte manipulation.

I'd like a unix-style command line program (with the obvious issue that it's actually running via Java, but I'll not worry about that detail), and I'd like it to take the following parameters:

-v = display version
-? = display some help on how to use the program

-e = encode
-d = decode
Default to encode

-f filename
Filename containing data to encode/decode.

-t text
Text to encode/decode

If neither -v, -?, -f or -t are specified, accept input from stdin.

Output to stdout. Errors go to stderr and include a stack trace.

JRE to be 1.5 or above - you can use 1.5/5 features, but nothing from 1.6/6.
-----------------------------------------------------------------------------

I am new to java and although I have done some programming I am not really that clear on how to start on this. By the end of the challenge I also have to understand how I put it together so I am not really looking for the complete solution, simply how to get there. I have doubts about the following regarding the command line tool:

> How do I go about creating a unix-style command line program that uses stdin, stdout and stderr.

> Is there a standard way to deal with parameters?

To be honest all I need is some advice that will point me in the right directions.

Thank you.