random-access

Read a file while it's being written

萝らか妹 提交于 2019-12-20 04:36:14
问题 I have to read the tomcat log file,and after some time(for example:one hour) I will read the file again(just for the new added content),so I create the RandomAccessFile to record the last postion I completed,and use the BufferedReader.readLine() method. However,I found that sometime I can not read the whole line of the file. For example,the tomcat is tring to write the following content(just example): 192.168.0.0 localhost /index.html ..... And at this moment,when I read I may get the result

Reaching a specific line in a file using RandomAccessFile

廉价感情. 提交于 2019-12-19 06:26:08
问题 Is it possible to position cursor to the start of a specific line in a file through RandomAccessFile? For e.g. I want to change String starting at char 10 till 20 in line 111 in a file. The file has fixed length records. Is it possible to directly position the cursor to start of line 111 using RandomAccessFile ? Update: I used the following code. However, its returning null. Line length is 200 characters (which is 200 bytes if I am not wrong) File f = new File(myFile); RandomAccessFile r =

Random access gzip stream

帅比萌擦擦* 提交于 2019-12-18 02:41:40
问题 I'd like to be able to do random access into a gzipped file. I can afford to do some preprocessing on it (say, build some kind of index), provided that the result of the preprocessing is much smaller than the file itself. Any advice? My thoughts were: Hack on an existing gzip implementation and serialize its decompressor state every, say, 1 megabyte of compressed data. Then to do random access, deserialize the decompressor state and read from the megabyte boundary. This seems hard, especially

Buffered RandomAccessFile java

不羁的心 提交于 2019-12-17 08:53:17
问题 RandomAccessFile is quite slow for random access to a file. You often read about implementing a buffered layer over it, but code doing this isn't possible to find online. So my question is: would you guys who know any opensource implementation of this class share a pointer or share your own implementation? It would be nice if this question would turn out as a collection of useful links and code about this problem, which I'm sure, is shared by many and never addressed properly by SUN. Please,

Getting a random venue using actionscript with no repeat

冷暖自知 提交于 2019-12-13 04:19:16
问题 Hi users of stack overflow I am currently struggling with randomizing my data via as3 and xml. I can load in the xml fine and generate a random venue however when I click on the random button I have created, the same node is shown twice! Basically I just want to randomly select data with no repeat of the previous venue if this makes sense. My xml: <gallery> <venue> <name>1</name> <description>1</description> <picture>images/1.jpg</picture> <thumb>thumbs/1.jpg</thumb> <address>1</address>

Can and How do you use RandomAccessFile with a file contained on an FTP server?

二次信任 提交于 2019-12-13 03:47:53
问题 This problem pertains to Java By using RandomAccessFile I intend to be able to also modify the file without blanking it. 回答1: The FTP protocol only barely supports random access reads and writes. That is to say, an FTP client can use the REST command to start reading or writing from a particular offset, but it will always truncate the file from that point. 来源: https://stackoverflow.com/questions/510492/can-and-how-do-you-use-randomaccessfile-with-a-file-contained-on-an-ftp-server

C++ random access iterators for containers with elements loaded on demand

て烟熏妆下的殇ゞ 提交于 2019-12-12 16:05:15
问题 I'm currently working on a small project which requires loading messages from a file. The messages are stored sequentially in the file and files can become huge, so loading the entire file content into memory is unrewarding. Therefore we decided to implement a FileReader class that is capable of moving to specific elements in the file quickly and load them on request. Commonly used something along the following lines SpecificMessage m; FileReader fr; fr.open("file.bin"); fr.moveTo(120); //

Object serialization and random access in java

限于喜欢 提交于 2019-12-11 20:10:37
问题 Can you use Java's built in object serialization with a random access file? My motivation is my answer to this question. 回答1: You could use serialization with a random access file, but you'll have to build the infrastructure yourself. There is no way to get the size of serialization without actually serializing. I assume you want to store multiple serialized objects in the same file, so you'll need to do something like: Store the serialized objects, keeping track of the offsets within the

Data Structure(s) Allowing For Alteration Through Iteration and Random Selection From Subset (C++)

萝らか妹 提交于 2019-12-11 12:45:17
问题 Given a fixed-sized array A of objects, suppose a much smaller subset of these objects meet a certain criteria B. There are three tasks I want to complete with approximately equal frequency: I want to be able to change an object currently not meeting criteria B to meet criteria B at any time when accessing the object in A by index. I want to be able to change an object currently meeting criteria B to no longer meet criteria B when accessing the object in A by index. I also want to be able to

createReadStream multiple times on the same fd

穿精又带淫゛_ 提交于 2019-12-11 03:34:01
问题 In a previous question it seemed that the only way to do random-access reads from a file in node.js is to use fs.createReadStream() with its optional fd , start , and end fields. This worked fine in my simplest tests. But in my project I need to repeatedly read from different offsets of a binary file. This failed in a strange way so I came up with a minimal test case: var fs = require('fs'); fs.open('test.txt', 'r', function (err, fd) { if (err) { console.error('error opening file: ' + err);