java 上传文件以及各种视频图片!

package org.ibm2.book.vo;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;

public class File2 {
     private void Create(){
      String name = "e://qq.txt";
         File file = new File(name);
         if(!file.exists()){
          try {
     file.createNewFile();
     FileWriter fw = new FileWriter(name);
           fw.write("ni s na tou xin de zei!");
           fw.close();
   } catch (IOException e) {
   
    System.out.println(e.getMessage());
   }
         
         }
     }
     private void ReadText(){
      File file = new File("e://qq.txt");
      FileReader fr;
  try {
   fr = new FileReader(file);
   BufferedReader br = new BufferedReader(fr);
   String line = "";
      try {
    while((line = br.readLine()) != null){
     System.out.println(line);
    }
   } catch (IOException e) {
    e.printStackTrace();
   }
  }catch (FileNotFoundException e) {
   e.printStackTrace();
  }
     
     }
     private void Copy(){
     
      try {
       BufferedReader br = new BufferedReader(new FileReader("e://qq.txt"));
    BufferedWriter fw = new BufferedWriter(new FileWriter("f://aa.txt"));
    String line = "";
    while((line = br.readLine()) != null){
     fw.write(line + "/n");
    }
    br.close();
    fw.close();
  } catch (IOException e) {
   e.printStackTrace();
  }
     
     }
     private void copyty1(){
      try {
   BufferedInputStream bs = new BufferedInputStream(new FileInputStream("e://qq.rar"));
   BufferedOutputStream bts = new BufferedOutputStream(new FileOutputStream("f://jack"));
   int btmp;
   while((btmp = bs.read()) != -1){
    bts.write(btmp);
    btmp = bs.read();
   }
   
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
     }
     private void copyty2(){
      try {
   BufferedReader bs = new BufferedReader(new FileReader("e://qq.rar"));
   BufferedWriter bts = new BufferedWriter(new FileWriter("d://xxs"));
   String btmp;
   while((btmp = bs.readLine()) != null){
    bts.write(btmp);
    btmp = bs.readLine();
   }
   bts.flush();
   bs.close();
   bts.close();
   
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
     }
 public File2(){
       //Create();
      //ReadText();
       //Copy();
   //copyty1();
   copyty2();
     }
 
 public static void main(String[] args) {
  File2 file = new File2();

 }

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值