Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nigel Wade Newsgroups: comp.lang.java.help Subject: Re: Easy way to read the contants of a folder/directory and output contents to file? Date: Mon, 12 Dec 2011 15:44:34 +0000 Lines: 42 Message-ID: <9kmlr3Fmm1U1@mid.individual.net> References: <9kmij4FsduU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net mSL02dMbXxEV6tai2f8aaQ3243bDTwWppu82z1V4yTP1FCQAYr Cancel-Lock: sha1:2pGPSHnq2Jvl5McJE/19YlYxa50= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.18) Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:1436 On 12/12/11 15:12, Thee Chicago Wolf [MVP] wrote: >> On 12/12/11 14:42, Thee Chicago Wolf [MVP] wrote: >> >>> outFile.write(String.valueOf(list[i]+"\n")); >> >> Do you something against the PrintWriter.println(String) method? > > Well, in some code I'd written previous, I used .write instead of > .println. When I actually tried .println, the output I got was as > such: > > file1.txt > > file2.txt > > file3.txt > > > > Not so pretty right? > when using .write, I get: > > file1.txt > file2.txt > file3.txt > > > Which is exactly what I want. I asked this of another person as well. > I naturally though println would give me nice clean output as in my > second example. But it didn't. When I used .write, it did. So, I'm > sticking with .write. Do you have any idea why println would give me > such spaced output? If you append a "\n" to the filename that is what you'll get. println() prints a line of output with a line terminator. Hence there is no need to append a "\n". That saves both processing time (concatenating Strings is relatively slow) and unnecessary coding. -- Nigel Wade