java.io.RandomAccessFile.RandomAccessFile()のサンプル

2018年3月11日

javaコード
package com.arkgame.study;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class RandomAccessFileDemo {

public static void main(String[] args) {
String fileName = “C:\\soft" + File.separator + “kuaitest.txt";
File f = new File(fileName);
RandomAccessFile cft;
try {
cft = new RandomAccessFile(f, “rw");
cft.writeBytes(“abcde");
cft.writeInt(12);
cft.writeBoolean(true);
cft.writeChar('A’);
cft.writeFloat(1.21f);
cft.writeDouble(12.123);
cft.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {

e.printStackTrace();
}

}

}

VB.net

Posted by arkgame