Article View: borland.public.jbuilder.java.language
Article #7692cannot create a new file with identical name to an existing folder in the same path
From: Yonatan Taub
Date: Sun, 27 May 2001 21:11
Date: Sun, 27 May 2001 21:11
34 lines
1658 bytes
1658 bytes
The following short program:
===================
import java.io.*;
public class CreateFile {
public static void main(String[] args) throws Exception {
String path = "d:\\pd_projects\\test";
File file = new File(path);
file.mkdir();
file.createNewFile();
}
}
produces an exception:
===============
java.io.IOException: Access is denied
at java.io.Win32FileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:693)
at CreateFile.main(CreateFile.java:10)
Exception in thread "main"
If I re-order the code so that the file will be created before the
directory, the file is created but the directory does not and no exception
is thrown.
Can anyone help me on this?
Technical Details
Message-ID:
<3b115fe8$2_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!skynet.be!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,918686e0c4316985,start X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-05-27 13:22:02 PST From: "Yonatan Taub" <taubu@tms.huji.ac.il> Newsgroups: borland.public.jbuilder.java.language Subject: cannot create a new file with identical name to an existing folder in the same path Date: Sun, 27 May 2001 23:11:08 +0200 Lines: 36 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2462.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2462.0000 NNTP-Posting-Host: 132.64.13.57 Message-ID: <3b115fe8$2_1@dnews> X-Trace: dnews 990994408 132.64.13.57 (27 May 2001 13:13:28 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!skynet.be!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews