/*
* 功能:读取A.tex内容删除第一个字符然后写到B.txe 在删除A.txe能实现么?
*/
package com.pangzihua;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public class copyAtoB
{
public static void main(String[] args) throws Exception
{
File f1 = new File("D:A.txt") ;
File f2 = new File("D:B.txt") ;
InputStream input = new FileInputStream(f1) ;
byte[] b = new byte[2048] ;
int len = 0 ;
int temp = 0 ;
while((temp = input.read())!=-1){
b[len] = (byte)temp ;
len++ ;
}
String str = new String(b,1,len) ;
OutputStream out = new FileOutputStream(f2) ;
out.write(str.getBytes()) ;
input.close() ;
out.close() ;
f1.delete() ;
System.out.println("任务完成");
}
} |