在Xml 中有时候定义 id 搞成了
<TextView android:text="@+id/mytext"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
写的虽然是错误的,但是 居然R.id.mytext存在!!调用时候会报空指针异常。
java创建文件和文件夹 的File类 ,对"/" 也即是File.separator 不敏感啊!我输入那么多分隔符居然只被当作一个"/"
import java.io.*;
public class Test {
public static void main(String[]arg) {
/* InputStreamReader isr = new InputStreamReader(new
FileInputStream(new File("C:\\Users\\joychine\\Desktop\\新建文本文档.txt")));
byte [] temp = new byte[4*1024];
int s = 0;
if((s=read(temp))!=-1)
System.out.println(s); */
File f = new File("D:/duomi"+File.separator+File.separator+File.separator+File.separator+"//新建文件夹/新建文件夹2");//这句话居然能编译而且运行!
File f1 = new File(f,"/t11xt.txt");
System.out.println(f.getName());
System.out.println(f1.getName());
System.out.println(f.getPath());
System.out.println(f1.getPath());
try {
f.mkdir();
f1.createNewFile();
} catch (Exception e){
e.printStackTrace();
}
}
}