write

Why does RandomAccessFile use int as offset

I am writing some data access test implementation and I need random access to file content. Here's the code: RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rwd"); final byte b[] = IOUtils.toByteArray(source); randomAccessFile.write(b, (int) offset, size); where offset has type long. Why doesn't RandomAccessFile provi...

Can a recursive function write to a file in C++?

I'm going to have two class functions. The first class function opens the file. Then it calls a second function that writes to the file and recursively calls itself. When the second function finishes, the original function closes the file. Is it possible to do this? ...

Set Excel sheet as datasource to Gridview .

Hi, I have the excel sheet , I want to keep it as datasource to the gridview . gridview will be editable so whatever the data updated sholud be write to again in excel sheet with respected location in sheet. How can i do this ? Please help me . ...

Memcached set() fails: WRITE FAILURE

So Memcached fails to write certain keys, getResultMessage() says WRITE FAILURE I'm using this in setup: $this->mmcache = new Memcached(); $this->mmcache->addServer('localhost',11211, 100); $this->mmcache->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $this->mmcache->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY...

Reading/Writing PDF Files in Visual C# Windows Forms

Hi All For a client, I need to be able to read and write PDF files. There are two downsides to this: I don't know how. I can't use any third-party copmonents/libraries. Can somebody please point me into the right direction where I might be able to learn how to begin reading and writing PDF files? I'm not asking for code or anything...

C++, read and write to a binary file at the same time

Hi I wanted to know if it's possible to read a byte from a binary file with "fstream" and then change that byte and write it back. I tried this code but it didn't work and nothing happens but I'm sure it reads correctly. file.open(path, ios::in|ios::out|ios::binary|ios::ate); file.seekg(0, ios::end); int size=file.tellg(); file.seekg(0,...

How to write to file in large php application(multiple questions)

What is the best way to write to files in a large php application. Lets say there are lots of writes needed per second. How is the best way to go about this. Could I just open the file and append the data. Or should i open, lock, write and unlock. What will happen of the file is worked on and other data needs to be written. Will this ...

I need to write a .DDS file cross-platform, can someone point me to example?

I need to create a .DDS file with code that runs on both OSX and Windows. Although the format doesn't look difficult, I'd still like an example of writing the file. Note I don't need to read it, just write it. C or C++ and RGBA bitmap. ...

Unable to write in kernel memory via Linux kernel module (Ubuntu)

Hey I'm trying to overwrite certain pieces in kernel memory (Linux 2.6.31, Ubuntu 9.10) in a virtual machine (using VirtualBox) via a kernel module. Whenever I'm doing this I get this error [27154.303726] BUG: unable to handle kernel paging request at 0xc05769bc My code: unsigned char *p = (unsigned char *) c05769bc; p[1] = (add...

How to write back to a certain cell in google doc spreadsheet using python

So the problem is, i get some information from first column of the row (for example A2 ) from the spreadsheet, then i will do some checking with that information, after that i want to write back to the next column in the row the result, how do i do that? Is there a certain function to allow me to indicate the column behind, in front, abo...

How can I write a folder of WPF image resources to disk?

I have a folder in my WPF app "Images" that has several .png files with their Build Action set to Resource. These are built into my binary since I can reference them in XAML. I would like to write these to disk in the temp folder. How do I do this? I have found several answers referring to Embedded Resources, but not just plain resourc...

Serial port : not able to write big chunk of data

Hi I am trying to send text data from one PC to other using Serial cable. One of the PC is running linux and I am sending data from it using write(2) system call. The log size is approx 65K bytes but the write(2) system call returns some 4K bytes (i.e. this much amount of data is getting transferred). I tried breaking the data in chunks...

How to open textfile and write to it append-style with php?

How do you open a textfile and write to it with php appendstyle textFile.txt //caught these variables $var1 = $_POST['string1']; $var2 = $_POST['string2']; $var3 = $_POST['string3']; $handle = fopen("textFile.txt", "w"); fwrite = ("%s %s %s\n", $var1, $var2, $var3, handle);//not the way to a...

Writing photos (and other things) to disk and getting them later in iphone

I'm trying to write an image to disk: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSString* savePath = [documentsPath stringByAppendingPathComponent:@"photo"]; BOOL result = [data writeToFile:savePath atomically:YES];...

Java BufferedWriter, OutputStreamWriter able to write to closed FileOutputStream

I was expecting the following code to throw an exception when I goto write data to the Stream: File file = new File("test.txt"); FileOutputStream fs = new FileOutputStream(file); OutputStreamWriter ow = new OutputStreamWriter(fs); BufferedWriter writer = new BufferedWriter(ow); fs.close(); try { ow.write(65); writer.write("tes...

Read/Write Excel Files Directly To/From Memory

Several people have asked, in a roundabout way, but I have yet to see a workable solution. Is there any way to open an excel file directly from memory (like a byte[]) ? Likewise is there a way to write a file directly to memory? I am looking for solutions that will not involve the hard disk or juggling temporary files. Thanks in adva...

Write set of integers to std::ofstream and be able to read them back

Hello, I need to write a bunch of unsigned integers to std::ofstream in binary mode: std::ofstream f; f.open("some path", std::ios::out | std::ios::binary); // some loop { unsigned int k = get_k(); // may product numbers from 0 to 65535 f << k; } f.close(); They are written to the output file "as is" w/o any delimiter. So when I'...

How can I write to the same file in different subroutines in Perl?

I'm having some problems writing data into a file using Perl. sub startNewOrder{ my $name = makeUniqueFileName(); open (ORDER, ">$name.txt") or die "can't open file: $!\n"; format ORDER_TOP = PRODUCT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<CODE<<<<<<<<AANTAL<<<<EENHEIDSPRIJS<<<<<<TOTAAL<<<<<<< . format ORDER = @<<...

How the reading from and writing to sockets are synchronized?

We create a socket. On one side of the socket we have a "server" and on another side there is a "client". Both, the server and client, can write to and read from the socket. It is what i understand. I do not understand the following things: If a server reads from the socket, does it see in the socket only those stuff which was written ...

Writing/Reading struct w/ dynamic array through pipe in C

I have a struct with a dynamic array inside of it: struct mystruct{ int count; int *arr; }mystruct_t; and I want to pass this struct down a pipe in C and around a ring of processes. When I alter the value of count in each process, it is changed correctly. My problem is with the dynamic array. I am allocating the array as such: mys...