randomaccessfile

In-memory version of Java's FileChannel

I'm in the process of making some changes to a library that I'm using. In order to reduce memory usage the library is writing its temporary data to disk instead of keeping it in memory. However, for my usage scenario it is more efficient to keep it in memory. It also has some concurrency issues, because it has constant names for its temp...

Add Hexadecimal Header Info to JPEG File Using Java

I need to add header info to a JPEG file in order to get it to work properly when shared on some websites, I've tracked down the correct info through a lot of Hex digging, but now I'm kind of stuck trying to get it into the file. I know where in the file it needs to go, and I know how long it is, my problem is that RandomAccessFile just...

Java RandomAccessFile - dealing with different newline styles?

Hey, I'm trying to seek through a RandomAccessFile, and as part of an algorithm I have to read a line, and then seek backwards from the end of the line E.g String line = raf.readLine(); raf.seek (raf.getFilePointer() - line.length() + m.start() + m.group().length()); //m is a Matcher for regular expressions I've been getting loads ...

java.io.FileNotFoundException when using RandomAccessFile to create file

Hey guys, I'm encountering a FileNotFoundException when I try to make a file using RandomAccessFile: RandomAccessFile file = new RandomAccessFile("/test.jpg", "rw"); I don't now how to get around this. It's driving me nuts. Thanks ...

Does FileInputStream.skip() do a seek?

Hi all, I want to copy the last 10MB of a possibly large file into another file. Ideally I would use FileInputStream, skip() and then read(). However I'm unsure if the performance of skip() will be bad. Is skip() typically implemented using a file seek underneath or does it actually read and discard data? I know about RandomAccessFi...

deleting random access file in java

I've created a random access file as follows: RandomAccessFile aFile = null; aFile = new RandomAccessFile(NetSimView.filename, "rwd"); I want to delete the file "afile". can anyone suggest me how to do it? ...