file-io

Why does File::Slurp return a scalar when it should return a list?

I am new to the File::Slurp module, and on my first test with it, it was not giving the results I was expecting. It took me a while to figure it out, so now I am interested in why I was seeing this certain behavior. My call to File::Slurp looked like this: my @array = read_file( $file ) || die "Cannot read $file\n"; I included the "...

Spaces while using "Print" in VBA

For some reason I am getting a lot of spaces in front of each value while trying to print to a flat text file. 'append headers Cells(start_row - 2, 1).Select For i = 1 To ActiveCell.SpecialCells(xlLastCell).Column If ActiveCell.Offset(0, 1).Column = ActiveCell.SpecialCells(xlLastCell).Column Then Print #finalCSV, Cells(start...

Ruby - Writing Hpricot data to a file

Hey everyone, I am currently doing some XML parsing and I've chosen to use Hpricot because of it's ease of use and syntax, however I am running into some problems. I need to write a piece of XML data that I have found out to another file. However, when I do this the format is not preserved. For example, if the content should look like t...

Foreach File in a Folder in Flash?

Hey, I have an image slideshow program working right now and it takes in a folder of a hard coded in number of images. I would like to change this so that it can take in a folder and will display all of them no matter the number. Is there a way to do this in flash? I'm thinking something like the foreach loop in perl or other scripting...

Append data into a file using Apache Commons I/O

The FileUtils.writeStringToFile(fileName, text) function of Apache Commons I/O overwrites previous text in a file. I would like to append data to my file. Is there any way I could use Commons I/O for the same? I can do it using normal BufferedWriter from Java but I'm curious regarding the same using Commons I/O. ...

python open does not create file if it doesnt exist

I am using Python. What is the best way to open a file in rw if it exists, or if it does not, then create it and open it in rw? From what i read, file = open('myfile.dat', 'rw') should do this, no? it is not working for me (python 2.6.2) and im wondering if it is a version problem, or not supposed to work like that or what. The bottom...

Vista seems to prevent .net from reading/updating file attributes.

Hello everyone! The following function copies a file from Source & Path to Dest & Path, normally setting file attributes to normal before copying. Yet, a user of my app has reported it to fail when copying readonly files, returning a permissions-related error. The user is however running the code as administrator, and the error happens...

Online Image Slideshow Question. File Access Problems.

Hi, I have a flash .swf file that I embed on my webpage. On my server I have the .swf file and multiple image folders. I would like to load every file in one of those folders into the flash slideshow. How should I go about doing this? I tried used Air but it doesn't work on my system as an application so I doubt it will work online. ...

xquery escape a bracket

how do i grab a file accross the network with brackets in the name? i.e. fn:doc("file:////machine/folder/folder2/fi[le]1.xml") fn:encode-for-uri() tries to grab locally escape-uri function is not an option because its been dropped. thanks ...

How do make my encryption algorithm encrypt more than 128 bits?

OK, now I have coded for an implementation of AES-128 :) It is working fine. It takes in 128 bits, encrypts and returns 128 bits So how do i enhance my function so that it can handle more than 128 bits? How do i make the encryption algorithm handle larger strings? Can the same algorithm be used to encrypt files? :) The function def...

How to run a set of SQL queries from a file, in PHP?

I have some set of SQL queries which is in a file(i.e query.sql), and i want to run those queries in files using PHP, the code that i have wrote is not working, //database config's... $file_name="query.sql"; $query=file($file_name); $array_length=count($query); for($i=0;$i<$array_length;$i++) { $data .= $query[$i]; } echo $data; ...

best practices question: How to save a collection of images and a java object in a single file? File is read to be rendered

Hi all, I am making a java program that has a collection of flash-card like objects. I store the objects in a jtree composed of defaultmutabletreenodes. Each node has a user object attached to it with has a few string/native data type parameters. However, i also want each of these objects to have an image (typical formats, jpg, png etc)...

How to make an Android app the default for a filetype?

I need my app to be the default action for opening a particular file type. How do I control this? Also, how can my app access the file being opened? Thanks. ...

How to read a single character at a time from a file?

I want to read a single character at a time from a file in python. Can anyone tell me how can I do this? ...

What is the easiest way to loop through a folder of files in C#?

I am new to C# and am trying to write a program that navigates the local file system using a config file containing relevant filepaths. My question is this: What are the best practices to use when performing file I/O (this will be from the desktop app to a server and back) and file system navigation in C#? I know how to google, and I ha...

Random Loss of precision in Python ReadLine()

Hi all, We have a process which takes a very large csv (1.6GB) and breaks it down into pieces (in this case 3). This runs nightly and normally doesn't give us any problems. When it ran last night, however, the first of the output files had lost precision on the numeric fields in the data. The active ingredient in the script are the...

getting directory name in java

how to get the directory name for a particular file on the drive in java? for example i have a test.java under a test directory on my D drive.how do i find the directory name for this test.java? ...

How to handle mp4 files with Java?

Mp3 files can be handled using this mp3 SPI support, but I'm not finding something similar to mp4 files. Any help would be appreciated. --UPDATE What I want to do is get the file's size, as I do with wave files using this code: AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file); AudioFormat format = audioInputS...

Generic file container for quick read of data

Since there are some major privacy issues with alot of social networking sites I am trying to think about alternatives. One is to let the user keep all the information stored in some kind of file container. Now, I haven't found a single type of container that can hold "generic" information. Only for audio/video. What I want is a containe...

How to read a file from bottom to top in Ruby?

I've been working on a log viewer for a Rails app and have found that I need to read around 200 lines of a log file from bottom to top instead of the default top to bottom. Log files can get quite large, so I've already tried and ruled out the IO.readlines("log_file.log")[-200..-1] method. Are there any other ways to go about reading a...