binaryfiles

RandomAccessFiles don't close until application exit

余生长醉 提交于 2019-12-25 00:15:25
问题 I'm working on a project where I'm using RandomAccessFile. The biggest issue I am having is that even though I close the file after it being accessed the file does not close until the entire application exits. Is this standard behavior or does anyone have some idea what's going on? The code basically looks like: RandomAccessFile raf = new RandomAccessFile(f); //do stuff raf.close(); Both sections where I am using a RandomAccessFile are like this (i.e. I am 100% sure that I am calling close on

Grouping up students records in a Binary File in C++ Based on their Batch Number?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 21:42:00
问题 im working on a console application in C++ (I'm a beginner) and the purpose is to make a small application that can store, read and modify students records Now, i want to group up data of binary file (class9.dat) such that all the students with common batch id ( char type batch[5] ) should stuck together , by saying "stuck together", i mean if initially, consider binary file consider data in this form [Tom , 2] [Harry, 1] [Peter, 2] [Stephen, 1] [Henry , 0] then, after stucking data together

Content of Binary Output File Created With Output Stream

倖福魔咒の 提交于 2019-12-24 19:18:57
问题 This code compiles and does execute. It simply print the content into a binary format. However the output differs from what I expected, namely: Output file size should be much smaller that those created with std::cout. The content of output file should be compressed, hence when we open it in editor, we should not be able to see the content. But why the code below doesn't do as I hope it does? How can I modify it accordingly? #include <iostream> #include <vector> #include <fstream> #include

Fastest way to read a binary file with a defined format?

筅森魡賤 提交于 2019-12-24 19:18:49
问题 I have large binary data files that have a predefined format, originally written by a Fortran program as little endians. I would like to read these files in the fastest, most efficient manner, so using the array package seemed right up my alley as suggested here. The problem is the pre-defined format is non-homogeneous. It looks something like this: ['<2i','<5d','<2i','<d','<i','<3d','<2i','<3d','<i','<d','<i','<3d'] with each integer i taking up 4 bytes, and each double d taking 8 bytes. Is

Java : How to find string patterns in a LARGE binary file?

狂风中的少年 提交于 2019-12-24 18:02:40
问题 I'm trying to write a program that will read a VERY LARGE binary file and try to find the occurrence of 2 different strings and then print the indexes that matches the patterns. For the example's sake let's assume the character sequences are [H,e,l,l,o] and [H,e,l,l,o, ,W,o,r,l,d] . I was able to code this for small binary files because I was reading each character as a byte and then saving it in an Arraylist . Then starting from the beginning of the Arraylist , I was comparing the byte

Java : How to find string patterns in a LARGE binary file?

风流意气都作罢 提交于 2019-12-24 18:02:34
问题 I'm trying to write a program that will read a VERY LARGE binary file and try to find the occurrence of 2 different strings and then print the indexes that matches the patterns. For the example's sake let's assume the character sequences are [H,e,l,l,o] and [H,e,l,l,o, ,W,o,r,l,d] . I was able to code this for small binary files because I was reading each character as a byte and then saving it in an Arraylist . Then starting from the beginning of the Arraylist , I was comparing the byte

So I'm having trouble understanding files in C++

时光毁灭记忆、已成空白 提交于 2019-12-24 16:01:48
问题 I just started learning files and I understand how to set it up and get it to work. I have to write this program where I have to allow the user to enter some information and have the user also update and adjust any data, using binary. So I can write up until the point where the user can write to and read from the file. But I don't know how to let the user adjust data or add data. #include <iostream> #include <fstream> #include <string> using namespace std; class client { public: string name;

Exact same file and code. So why does the binary of my docx file always end differently?

∥☆過路亽.° 提交于 2019-12-24 14:21:52
问题 We take a (non-corrupted) .docx file from our server and post it via httprequest to an API. When downloading it from the API it comes out corrupted. I 99% sure that this is down to the code that posts the file, not the API. It turns out the corrupted file had some extra characters in the binary - I thought it would be pretty easy to find out where they came from and remove them. Boy was I wrong. I've since realised that every time we post the file, the binary ending is slightly different. We

Outputting a Binary String to a Binary File in C++

耗尽温柔 提交于 2019-12-24 12:58:06
问题 Let's say I have a string that contains a binary like this one "0110110101011110110010010000010". Is there a easy way to output that string into a binary file so that the file contains 0110110101011110110010010000010? I understand that the computer writes one byte at a time but I am having trouble coming up with a way to write the contents of the string as a binary to a binary file. 回答1: Use a bitset: //Added extra leading zero to make 32-bit. std::bitset<32> b(

Writing different structs to a file in C++? [closed]

筅森魡賤 提交于 2019-12-24 12:43:10
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I need a way to write structures of three different kinds to a binary file, which later has to be searched. (As in, for example, struct A has two fields, an int and a char; struct B has int and a long; I need to output all structures whose int equals the one given from keyboard). I understand how