package random;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
public class RandomIOImpl {
public static void main(String[] arges){
File file = new File("c:\\测试\\a.txt");
RandomAccessFile raf = null;
RandomAccessFile raf1 = null;
try {
raf = new RandomAccessFile(file,"rw");
byte[] temp = new byte[1000];
raf.read(temp,100,200);
File file1 = new File("c:\\测试\\c.txt");
if(!file1.exists()){
file.createNewFile();
}
raf1 = new RandomAccessFile(file1,"rw");
raf1.write(temp,100,180);
raf.close();
raf1.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
public class RandomIOImpl {
public static void main(String[] arges){
File file = new File("c:\\测试\\a.txt");
RandomAccessFile raf = null;
RandomAccessFile raf1 = null;
try {
raf = new RandomAccessFile(file,"rw");
byte[] temp = new byte[1000];
raf.read(temp,100,200);
File file1 = new File("c:\\测试\\c.txt");
if(!file1.exists()){
file.createNewFile();
}
raf1 = new RandomAccessFile(file1,"rw");
raf1.write(temp,100,180);
raf.close();
raf1.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}