代码如下:
import java.io.*;
public class IoTest {
public static void main(String[] args) throws Exception {
File parent = new File("D:");
String child ="1"+File.separator+"1.txt";
File f = new File(parent, child);
f.createNewFile();
}}
我想在D盘创建个1文件夹,然后在里面建个1.txt文件,为什么显示:
Exception in thread "main" java.io.IOException: 系统找不到指定的路径。
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at a.IoTest.main(IoTest.java:9)
求高手讲解,感激不尽!!
import java.io.*;
public class IoTest {
public static void main(String[] args) throws Exception {
File parent = new File("D:");
String child ="1"+File.separator+"1.txt";
File f = new File(parent, child);
f.createNewFile();
}}
我想在D盘创建个1文件夹,然后在里面建个1.txt文件,为什么显示:
Exception in thread "main" java.io.IOException: 系统找不到指定的路径。
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at a.IoTest.main(IoTest.java:9)
求高手讲解,感激不尽!!
解决方案 »
- 一道java题目,大家来设计一下,看看谁的最简单!
- 怎么能让乌龟绕着我屏幕动起来呢,不用鼠标和键盘控制
- 关于Servlet程序
- readObject writeObject为什么这么暧昧
- help, 超大String和byte[]
- 帮我看一下这个存储过程的调用哪出错了
- Win2000下,JDK 1.4.1_01 在运行图形程序时会死机,有谁也碰到了吗
- 请教一个小问题,请各位高手赐教
- 如何检测一个java.sql.ResultSet对象是否eof?
- 去哪里弄一个SCJP考试的CramBible?
- getRealpath()方法求解
- 输出101~200的质数(请问这个if (!f)是什么意思啊?)
public class IoTest {
public static void main(String[] args) throws Exception {
File parent = new File("D:");
String child =File.separator+"1.txt";
File f = new File(parent, child);
f.createNewFile();
}}
String child ="1"+File.separator+"1.txt";
File f = new File(parent, child);
这两行代码,拼接出来的路径不是d:\1.txt 是d:1\1.txt所以无法找到指定路径
File path = new File(root,"1");
if(!path.exists()) path.mkdirs();
File file = new File(path,"1.txt");
boolean success = file.createNewFile();