From: Brian Candler Date: 2007-02-07T23:31:15+09:00 Subject: Re: Parse csv similar file On Wed, Feb 07, 2007 at 07:28:03PM +0900, Rebhan, Gilbert wrote: > i had to add the Extension .txt (this may be altered) > to the filename and did it like that = > > require 'fileutils' > SRCDIR="/path_to_src" > DSTDIR="/path_to_dst" > #EXT=".extension" > EXT=".txt" > > def copy_ticket(filename, folder, ticket, user, date, time) > srcdir = SRCDIR + File::SEPARATOR + folder > dstdir = DSTDIR + File::SEPARATOR + ticket + File::SEPARATOR + folder > filename=filename< ... > > is there a better way ? That's OK, just beware that the way you've done it you've modified the string which was passed in. e.g. a="foobar" copy_ticket(a, "/tmp", "E123", "x", "y", "z") puts a will print "foobar.txt" To avoid that: filename = filename + EXT (which creates a new String object, and then updates the local variable 'filename' to point to this new object) This is an interesting "small" file-chomping task. I wonder what the equivalent Java program would look like :-) B.