file-io

Listing Files On Directory On a TListView

I'm building a program that needs to on Form_Create, populate a TListView called FileList, the directory that I want to populate is where the compiled program is + \Files, as I never used a TListView I want to know how to do this? ...

c# Writing to a file without using using{}

Hi peeps I'm writing a little application whereby I want to write the results of the operations to a file. Basically what I want to do is open a stream to a file (I'm thinking FileStream, but am open to suggestions), write data to the file, then close it at a later date. So I've got a class called ReportFile, with methods: .Create( s...

Looking for solution ideas on how to update files in real time that may be locked by other software

I'm interested in getting solution ideas for a problem we have. Background: We have software tools that run on laptops and flash data onto hardware components. This software reads in a series of data files in order to do the programming on the hardware. It's in a manufacturing environment and is running continuously throughout the day....

Alternatives to using RFile in Symbian

This question is in continuation to my previous question related to File I/O. I am using RFile to open a file and read/write data to it. Now, my requirement is such that I would have to modify certain fields within the file. I separate each field within a record with a colon and each record with a newline. Sample is below: [email protected]:...

How to handle new files to process in cron job

How can I check files that I already processed in a script so I don't process those again? and/or What is wrong with the way I am doing this now? Hello, I am running tshark with the ring buffer option to dump to files after 5MB or 1 hour. I wrote a python script to read these files in XML and dump into a database, this works fine. My ...

how to overwrite a file if it exists?

I am using this to save a string value to a file: BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); writer.write(content); writer.close(); If the file exists, I get an error. ...

Renaming a directory in C#

Ok, so admittedly I'm pretty new to C#, but I couldn't find a DirectoryInfo.Rename(To) or FileInfo.Rename(To) method anywhere. It pissed me off, so I wrote my own, and I'm posting it here for anybody to use if they need it, because let's face it : the MoveTo methods are overkill and will always require extra logic if you just want to re...

Read file from end to start

I am trying to build a little tool for our messaging (WCF) component. The idea is to give responses based on previous trace logs for testing purposes. As the SOAP messages are very big we tend to have huge trace files. What i want to do is read the traces from end to start line by line (newest to oldest) in order to build my responses. A...

Ruby: Deleting last iterated item?

What I'm doing is this: have one file as input, another as output. I chose a random line in the input, put it in the output, and then delete it. Now, I've iterated over the file and am on the line I want. I've copied it to the output file. Is there a way to delete it? I'm doing something like this: for i in 0..number_of_lines_to_remov...

Remove Path From File Name

I'm developing a program that needs to parse the file name into a TTextField. How to remove the file extension I've already know(or think that I can do like this): var FName: String; FPath: String; begin FPath := OpenDialog1.FileName; FName := ChangeFileExt(FPath, ''); end; But how can I remove the file path from FName? ...

Java OutputStream equivalent to getClass().getClassLoader().getResourceAsStream()

I am attempting to Store() the change made to my application's Properties. The .Properties file is located in 'resources' package, which is different from the package that contains my UI and model. I opened the package using: this.getClass().getClassLoader().getResourceAsStream("resources/settings.properties") Is there a functional e...

Correct way to use XmlSerialization with frequent serializations

I have a list box that when an item is selected or deselected I want to save the changes to an xml file (so it is always up-to-date on the file and the user does not need a "save" button). While testing I occasionally am hitting this IOException: The process cannot access the file 'C:\MyPath\MyFile.xml' because it is being used by anot...

Read txt file in res/raw/ within Android NDK

I have a file within my application that I want to have included within the .apk for my android app that is a .txt file. My application is almost entirely written in C through the use of the NDK, using OpenGL as well. I know I can bundle the txt file by placing it in /res/raw/, but is there anyway I can access this within the android N...

get FileChannel without using java.io.* (use pure NIO)

Recently I got a comment to this answer that I should stay away from java.io if I want to use "pure NIO". This is the simplified code (copy a file): private static void copy(File source, File destination) throws IOException { long length = source.length(); FileChannel input = new FileInputStream(source).getChannel(); FileCha...

Java - Reading input from a file. java.io.FilterInputStream.available(Unknown Source)?

Hi. I haven't written any Java in years and I went back to refresh my memory with a simple 'read-from-file' example. Here is my code.. import java.io.*; public class filereading { public static void main(String[] args) { File file = new File("C:\\file.txt"); FileInputStream fs = null; BufferedInputStream b...

Fastest way to import CSV files in MATLAB

I've written a script that saves its output to a CSV file for later reference, but the second script for importing the data takes an ungainly amount of time to read it back in. The data is in the following format: Item1,val1,val2,val3 Item2,val4,val5,val6,val7 Item3,val8,val9 where the headers are on the left-most column, and the da...

Unit testing file write in Python

I am writing a wrapper for the ConfigParser in Python to provide an easy interface for storing and retrieving application settings. The wrapper has two methods, read and write, and a set of properties for the different application settings. The write method is just a wrapper for the ConfigParser's write method with the addition of also...

Atomic file write operations (cross platform)

How do I build up an atomic file write operation? The file is to be written by a Java service and read by python scripts. For the record, reads are far greater than writes. But the write happens in batches and tend to be long. The file size amounts to mega bytes. Right now my approach is: Write file contents to a temp file in same d...

Locking and unlocking files using C API in Ubuntu LInux

Hello, How can I lock a file for a specified period of time (10 seconds) using the C language in Ubuntu Linux ? ...

How to check if a file exists in a war file?

How can I check if a file exists in a war file? I know I can use boolean doesExist = new File(myfile).exists(); but how do I use that in a java class in the war? The file.getAbsolutePath() just shows where the war file is running. I need to check if there is an image in another directory in the war that matchs the filename in the w...