Java RandomAccessFile Create getRandomAccessFile()

Here you can find the source of getRandomAccessFile()

Description

get Random Access File

License

Open Source License

Declaration

public static RandomAccessFile getRandomAccessFile() throws FileNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.FileNotFoundException;

import java.io.RandomAccessFile;

public class Main {
    private static final String db_name = "TestInterceptDB.data";
    private static RandomAccessFile randomAccessFile = null;

    public static RandomAccessFile getRandomAccessFile() throws FileNotFoundException {
        if (randomAccessFile == null) {
            try {
                randomAccessFile = new RandomAccessFile(new File(db_name), "rw");
            } catch (FileNotFoundException e) {
                throw new FileNotFoundException(e.getMessage());
            }/*from w  w  w .  j ava 2 s.c  om*/
        }
        return randomAccessFile;
    }
}

Related

  1. getRandomAccessFile(String path, String charEncoding)