JAVA和PHP文件操作总结
JAVA文件操作总结
File类
File f = new File(path);
path为实际路径,该路径可以是文件,或文件夹,也可以是不存在的。
f.exists() 可以判断该路是否存在。
f.isDirectory() 可以判断是否是文件夹。
f.mkdirs(); 递归创建文件夹
File和输入输出流之间纽带FileInutStream,FileOutputStream
URL url = new URL(strUrl);
BufferedInputStream bis = new BufferedInputStream(url.openStream()); //用buffer
OutputStream os = new FileOutputStream(new File(path + newName));
byte[] bytes = new byte[1024];
int len;
while((len = bis.read(bytes)) > 0) { //循环读取1024字节
os.write(bytes, 0, len); //写入1024字节
}
bis.close();
os.flush();
os.close();
相关文档:
贴段代码,有少许注释:
package ibees;
import java.util.Arrays;
public class BinarySearch {
/**
* @param args
*/
public static void main(String[] args) {
double[] src = new double[]{1.3,9.9,10.89,12.89,89.0};
System.out.println(new BinarySearch().binarySearch(src, 89.0));
}
......
今天继续学习java和android平台 java的学习算是补充,因为没有java基础也做不出什么东西来
今天看到java用this关键字来重载构造方法,在这里做个笔记class a_sample{
public int x,y.z;
a_sample(int x){
this.x=x;
}
a_sample(int x,int y){
this(x);
this.y=y;
}
a_sample(int x ......
级别: 中级
Jack D Herrington
(jherr@pobox.com
), 高级软件工程师, Leverage Software Inc.
2006 年 10 月 19 日
设计模式只是为 Java™ 架构师准备的 —— 至少您可能一直这样认为。实际上,设计模式对于每个人都非常有用。如果这些工具不是 “架构太空人” 的专利,那么它们又是什 ......