random-access

why we can't Serialize these objects?

女生的网名这么多〃 提交于 2020-01-06 08:23:29
问题 why we can't Serialize objects into Random Access file ? and on the other hand we can serialize objects into sequential access file ? ""C# does not provide a means to obtain an object’s size at runtime. This means that, if we serialize the class, we cannot guarantee a fixed-length record size "" (from the book that i read in). so we cannot read the the random access file because we don't know every object size in the file so how we could do seeking ?????? 回答1: Any object marked with the

How do I delete a record from my random access file?

自闭症网瘾萝莉.ら 提交于 2020-01-03 05:53:30
问题 I was wondering how I could delete a record from my random access file. Here's how I add to my RAF, not sure how to delete it though :X public void addNewStudent(String name, String formClass, String emailAddress, String country1, String country2, String universityChoice) { try { RandomAccessFile theFile = new RandomAccessFile("studentData.dat","rw"); long records = (theFile.length()+299)/300; //Number of records if(theFile.length()>0) //Check if the file is empty or not { for(long x=0;x

Random-access container that does not fit in memory?

浪子不回头ぞ 提交于 2020-01-02 03:54:43
问题 I have an array of objects (say, images), which is too large to fit into memory (e.g. 40GB). But my code needs to be able to randomly access these objects at runtime. What is the best way to do this? From my code's point of view, it shouldn't matter, of course, if some of the data is on disk or temporarily stored in memory; it should have transparent access: container.getObject(1242)->process(); container.getObject(479431)->process(); But how should I implement this container? Should it just

What do we mean with pages/blocks for files in the application level?

依然范特西╮ 提交于 2019-12-25 03:12:31
问题 When I read about files in textbooks it seems that some concepts I knew about OS are repeated for files on the application level. For example the terms block and page are used for logical representation of data in files (so we are not in the HD level organization). But I can not understand what is the idea here. Do we in the application define a block size and a page size and use that when accessing files e.g. using NIO or blocking IO? How would we define these sizes normally? Arbitrarily? Am

Can't Over write on a specific location on a file. Over write on a specific location deletes all the contents before it and moves the value after it

爷,独闯天下 提交于 2019-12-24 09:55:16
问题 In my project, there is a need to read and write to binary file, basically serializing linked lists in a file, where I store the value in binary format and remember the tellp()/tellg() offset, how ever, I cannot do that. That erases all the contents in it to zero and instead of inserting it pushes the current content back. For Example, in the below program, I open a file, write values say 1,120,323. Then close it and read it, it shows the exact correct values 1,120,323. But When I try to

Converting Quick BASIC to VB.Net - Random Access Files

我是研究僧i 提交于 2019-12-22 09:31:05
问题 I'm trying to convert an old Quick BASIC program to VB.Net. There doesn't appear to be any direct replacement for the old file statements. Building a database seems like overkill for my simple needs. How can I do the following in VB.Net? OPEN "test.dat" FOR RANDOM AS #1 LEN = 20 FIELD #1, 10 AS a$, 10 AS b$ LSET a$ = "One" LSET b$ = "Two" PUT #1, 1 GET #1, 1 PRINT a$, b$ CLOSE #1 回答1: The Microsoft.VisualBasic.FileOpen, FilePut, and FileGet statements should be pretty direct replacements for

java.io.FileNotFoundException when using RandomAccessFile to create file

…衆ロ難τιáo~ 提交于 2019-12-22 05:26:12
问题 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 回答1: Try RandomAccessFile file = new RandomAccessFile(new File(getFilesDir(), "test.jpg"), "rw"); 回答2: From the documentation: FileNotFoundException - if the mode is "r" but the given file object does not denote an existing regular file, or if the mode begins with "rw" but

Efficiently choosing a random line from a text file with uniform probability in C?

孤者浪人 提交于 2019-12-22 04:14:11
问题 This is essentially a more constrained version of this question. Suppose we have a very large text file, containing a large number of lines. We need to choose a line at random from the file, with uniform probability, but there are constraints: Because this is a soft realtime application, we cannot iterate over the entire file. The choice should take a constant-ish amount of time. Because of memory constraints, the file cannot be cached. Because the file is permitted to change at runtime, the

What is the difference between file and random access file?

倖福魔咒の 提交于 2019-12-21 17:42:16
问题 what is the difference between file and random access file? 回答1: A random access file is a file where you can "jump" to anywhere within it without having to read sequentially until the position you are interested in. For example, say you have a 1MB file, and you are interested in 5 bytes that start after 100k of data. A random access file will allow you to "jump" to the 100k-th position in one operation. A non-random access file will require you to read 100k bytes first, and only then read

random seek in 7z single file archive

我们两清 提交于 2019-12-21 03:16:17
问题 Is it possible to do random access (a lot of seeks) to very huge file, compressed by 7zip? The original file is very huge (999gb xml) and I can't store it in unpacked format (i have no so much free space). So, if 7z format allows accessing to middle block without uncompressing all blocks before selected one, I can built an index of block beginning and corresponding original file offsets. Header of my 7z archive is 37 7A BC AF 27 1C 00 02 28 99 F1 9D 4A 46 D7 EA // 7z archive version 2;crc; n