Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!news-xxxfer.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: A strange behaviour of a File property Date: Fri, 11 Nov 2011 14:13:40 -0800 (PST) Organization: http://groups.google.com Lines: 27 Message-ID: <1281158.487.1321049620382.JavaMail.geo-discussion-forums@prou19> References: <5980efbc-9010-4145-b886-fe106c5ac2d5@c18g2000yqj.googlegroups.com> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 2620:0:1000:2404:224:d7ff:fe69:5838 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1321050524 1090 127.0.0.1 (11 Nov 2011 22:28:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 11 Nov 2011 22:28:44 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:2404:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9859 On Friday, November 11, 2011 8:25:11 AM UTC-8, Andreas Leitgeb wrote: > ale...@inwind.it wrote: > > public class Main { > > public static void main(String[] args){ > > File f = new File("."); // try to change the path > > ... > > > for(int i=0; i > file_array[i] = new File("." + "\\" + content[i]); > > First of all, did you change the path also here? > or better: define a variable and use it in both spots. > > Second, hardcoding "\\" is the worst approach at assembling a > file name from components. See the docu for File class for > a static field that contains the appropriate separator char > for the current platform. For test code, "/" is often good > enough (even on Windows). Or you could use one of: or -- Lew