易截截图软件、单文件、免安装、纯绿色、仅160KB

Java输入输出流 复制文件

   刚开始学习Java,一直想学但总是坚持不下来,回到家就想着玩游戏,看来是要下决心了,2010年要好好学习Java了.
   这是在网上看到的两个小例子,自己也做了一遍.
    1.
    try
{
FileInputStream in=new FileInputStream("C:/1.txt");
FileOutputStream out=new FileOutputStream("C:/2.txt");
byte[] by=new byte[1024];
do {
in.read(by, 0, 1024);
out.write(by);
} while (in.available()>0);
in.close();
out.close();
}catch(ArrayIndexOutOfBoundsException e)
{
e.printStackTrace();
}catch(IOException e)
{
e.printStackTrace();
}
   2.
try {
FileInputStream in=new FileInputStream("C:/1.txt");
FileOutputStream out= new FileOutputStream("C:/2.txt");
BufferedInputStream bufferedIn=new BufferedInputStream(in);
BufferedOutputStream bufferedOut=new BufferedOutputStream(out);
byte[] by=new byte[1];
while (bufferedIn.read(by)!=-1) {
bufferedOut.write(by);
}
//将缓冲区中的数据全部写出
bufferedOut.flush();
bufferedIn.close();
bufferedOut.close();

} catch (ArrayIndexOutOfBoundsException e) {
// TODO: handle exception
e.printStackTrace();
}catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}


相关文档:

java常用包

1、java.lang包:java的核心类库,包含了运行java程序必不可少的系统类,如基本数据类型、基本数学函数、字符串处理、线程、异常处理类等,系统缺省加载这个包
2、java.io包:java语言的标准输入/输出类库,如基本输入/输出流、文件输入/输出、过滤输入/输出流等等
3、java.util包:包含如处理时间的date类,处理变成数 ......

java各种字符串格式化

1、日期格式化
String tim = "2009-12-29";
String str = (new java.text.SimpleDateFormat("yyyy年MM月dd日")).format((new java.text.SimpleDateFormat("yyyy-MM-dd")).parse(tim));
返回:2009年12月29日
String now = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new java.util.Date());
返回当前时间 ......

Java程序调用存储过程应用举例

Java程序调用存储过程验证用户登录
package com.yzy.jdbc.dao;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import oracle.jdbc.OracleTypes;
public class LoginDao {
 public boolean loginValidate(String username, Stri ......

java四舍五入BigDecimal

java四舍五入
package Test;
import java.math.BigDecimal; //引入这个包
public class Test {
  public static void main(String[] args) {
   double i = 3.856;
   // 舍掉小数取整
   System.out.println("舍掉小数取整:Math.floor(3.856)=" + (int) Math.floor(i));
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号