Questions tagged [file-io]

File I/O is input/output that involves the file system. This could include performing operations on directories and files, such as creation and deletion, reading files, and writing output to files.

For an introduction on File I/O in C, see C Programming / File I/O on Wikibooks.

21104 questions
8
votes
1 answer

Why is average disk seek time one-third of the full seek time?

I have read in many books and papers, considering disk performance, that the average seek time is roughly one-third of the full seek time, but no one really offers any explanation about that. Where does this come from?
nikos
  • 2,893
  • 11
  • 30
  • 39
8
votes
1 answer

Most efficient file writing method for Linux video recorder

I'm working on an embedded Linux video recorder application which writes MP4 format video to a file (on FAT format SD card). Some complicating factors are that the video and audio data come from hardware codecs which have to be serviced with low…
blueshift
  • 6,742
  • 2
  • 39
  • 63
8
votes
4 answers

relative file paths in perl

I have a perl script which is using relative file paths. The relative paths seem to be relative to the location that the script is executed from rather than the location of the perl script. How do I make my relative paths relative to the location…
Dunc
  • 7,688
  • 10
  • 31
  • 38
8
votes
5 answers

Do I need to generate a second file to sort a file?

I want to sort a bunch of files. I can do sort file.txt > foo.txt mv foo.txt file.txt but do I need this second file? (I tried sort file.txt > file.txt of course, but then I just ended up with an empty file.)
Nagel
  • 2,576
  • 3
  • 22
  • 20
8
votes
2 answers

loading a variable from a .mat file into a differently named variable

Say I have a .mat file with several instances of the same structure, each in a different variable name. I want to process each instance found in a file (which I find using whos('-file' ...). I was hoping that load would let me specify the…
jhfrontz
  • 1,165
  • 4
  • 19
  • 31
8
votes
3 answers

Reading selective column data from a text file into a list in Java

Can someone help me to read a selective column of data in a text file into a list.. e.g.: if the text file data is as follows ------------- id name age 01 ron 21 02 harry 12 03 tom 23 04 jerry 25 ------------- from the above data if I need to…
Venkat Pathy
  • 151
  • 2
  • 3
  • 8
8
votes
2 answers

Simple way to convert a URL into a filename

I'm writing an asynchronous image downloader for Android and was just wondering, given an arbitary URL such as: http://www.android.com/images/brand/droid.gif What would be the best way to convert the unique url to a filename. I thought about…
Ljdawson
  • 12,091
  • 11
  • 45
  • 60
8
votes
1 answer

FileReader API: how to read files synchronously

I am trying to read a file which is selected using an input type file on the html page. I have implemented the function to read the file and the file content is able to be read. But the actual problem is that the reading of the content of the file…
AmGates
  • 2,127
  • 16
  • 29
8
votes
2 answers

Is it possible to configure the Build Configuration to automatically add suffixes for target platform?

is it possible to setup (ideally from GUI) the Build Configuration to automatically add suffixes to the output files according to the target platform ? I mean, I will have for instance library project named Project and I would like to…
Martin Reiner
  • 2,167
  • 2
  • 20
  • 34
8
votes
3 answers

Java saving/opening File objects

After painstakingly trying to implement TCP file transfer in my conference chat application using raw byte streams, I've decided it's much easier to send files that I want transferred through object streams. The files are sent and stored at their…
Richard Stokes
  • 3,532
  • 7
  • 41
  • 57
8
votes
1 answer

Performance drop with fputs after writing more than 2,5GB. Why?

Currently I'm working on a small program that reads large files and sorts them. After some benchmarking I stumbled upon a weird performance issue. When the input file got to large the writing of the output file took longer than the actual sorting.…
Aceonline
  • 344
  • 2
  • 12
8
votes
9 answers

FileNotFound (Access is denied) Exception on java.io

Why do I get this error when I run this program? This occurs after random iterations. Usually after the 8000th iteration. public static void main(String[] args) { FileWriter writer = null; try { for(int i = 0; i < 10000; i++) …
Varun Achar
  • 14,781
  • 7
  • 57
  • 74
8
votes
1 answer

PHP file size is unchanged after appending

I am facing a problem with PHP file I/O. $file = fopen("/tmp/test.txt", "w"); fwrite($file,"hi there\n"); fclose($file); echo filesize("/tmp/test.txt")."\n"; # displays 9 $file = fopen("/tmp/test.txt", "a"); fwrite($file,"hi…
8
votes
2 answers

Does writing a file to disk with Python open().write() ensure the data is available to other processes?

One Python process writes status updates to a file for other processes to read. In some circumstances, the status updates happen repeatedly and quickly in a loop. The easiest and fastest approach is to use to open().write() in one…
tahoar
  • 1,788
  • 3
  • 20
  • 36
8
votes
2 answers

How to close a file in python without assigning a variable

How do I close a file in python after opening it this way: line = open("file.txt", "r").readlines()[7]
Milo Wielondek
  • 4,164
  • 3
  • 33
  • 45