未命名

檔案下載:  39365175

 

import java.io.IOException;
import java.io.RandomAccessFile;

public class IO {
public void readFile(String path) {
try {
// 打開一個隨機訪問文件流,按讀寫方式
RandomAccessFile randomFile = new RandomAccessFile(path, "r");
// 文件長度,字節數

byte[] files= new byte[1024];
while(randomFile.read(files) != -1){
appendMethod("d:\\123.rar",files);
}
} catch (IOException e) {
e.printStackTrace();
}
}

public static void appendMethod(String fileName, byte[] content) {
try {
// 打開一個隨機訪問文件流,按讀寫方式
RandomAccessFile randomFile = new RandomAccessFile(fileName, "rw");//"r", "rw", "rws", or "rwd"
// 文件長度,字節數
long fileLength = randomFile.length();
// 將寫文件指針移到文件尾。
randomFile.seek(fileLength);
randomFile.write(content);
randomFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
IO io = new IO();
io.readFile("d:\\JDK_API_1_6_zh_CN.CHM");
}
}

 
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()