For a given set of text files, I need to find every "\" character and replace it with "\\". This is a Windows system, and my scripting language options are Javascript, VBScript, or Perl.
These files are largish (~10MB a piece), and there are a good number of them (~15,000). I've already come up with the following Javascript:
function...
Some one know a usable grib file format i/o library, i should use it on iphone
...
Does anyone know how I can read the first two characters from a file, using a bash script. The file in question is actually an I/O driver, it has no new line characters in it, and is in effect infinitely long.
...
I'm attempting to read the contents of a file in a medium trust environment (Go Daddy), and Im naturally getting SecurityException with FileIOPermission. Is there anyway around this?
...
I'm trying to replace a string in all the files within the current directory. for some reason, my temp file ends up blank. It seems my .write isn't working because the secondfile was declared outside its scope maybe? I'm new to python, so still climbing the learning curve...thanks!
edit: I'm aware my tempfile isn't being copied current...
I have a Visual Studio 2008 solution that contains a handful of projects. One project contains a WCF Service I'm deploying. That WCF Service references some code in one of the other projects. That code is trying to read a file that's in a folder in the WCF project. Pseudo-project structure:
Solution
Project1
myclass.cs
string ...
I had an issue where downloading to a local file was locking it until I killed the ruby script. On a hunch, I changed the form of the call and now it doesn't lock the file.
Can someone tell me why the second form below doesn't lock the file but the first one does?
This form locks the local file:
open(ver_local_zip, "w+").write(open(r...
Hello!
How to calculate the entropy of a file? (Or let's just say a bunch of bytes)
I have an idea, but I'm not sure that it's mathematically correct.
My idea is the following:
Create an array of 256 integers (all zeros).
Traverse through the file and for each of its bytes,
increment the corresponding position in the array.
At the en...
Hello!
Once I had the theory that on modern operating systems multithreaded
read access on the HDD should perform better.
I thought that:
the operating system queues all read requests,
and rearranges them in such a way, that it could read from the HDD more
sequentially. The more requests it would get, the better it could rearrange the...
I noticed a strange behaviour of File.Copy() in .NET 3.5SP1. I don't know if that's a bug or a feature. But I know it's driving me crazy. We use File.Copy() in a custom build step, and it screws up the character encoding.
When I copy an ASCII encoding text file over a UTF-8 encoded text file, the destination file still is UTF-8 encoded...
Hi there,
I have some current code and the problem is its creating a 1252 codepage file, i want to force it to create a UTF-8 file
Can anyone help me with this code, as i say it currently works... but i need to force the save on utf.. can i pass a parameter or something??
this is what i have, any help really appreciated
var out = new...
import java.io.*;
public class Demo{
public static void main(String[] args){
File f = new File("abc.txt") ;
try{
System.setOut(new PrintStream( new FileOutputStream(f) ) ) ;
}
catch(FileNotFoundException fnfe){
System.out.println(fnfe.getMessage()) ;
}
System.out.println("Hello\n") ;
...
I am using an FTPClient library to transfer files from a windows share to an FTP server.
The SendFile method of the library uses the following code:
FileStream stream = new FileStream(localFileName, FileMode.Open);
This results in a System.UnauthorizedAccessException being thrown, however I am able to open, rename and move the file u...
Hello! This looks like a simple question, but I didn't find anything similar here.
Since there is no file copy function in C, we have to implement file copying ourselves, but I don't like reinventing the wheel even for trivial stuff like that, so I'd like to ask the cloud:
What code would you recommend for file copying using fopen()/f...
I have a process which picks up a series of "xml" files. The reason I put xml in quotes is that that the text in the file does not have a root element which makes in invalid xml. In my processing, I want to correct this and open up each file add a root node to the beginning and end of each file, and then close it up. Here is what I ha...
I am trying to create a back up file for an html file on a web server.
I want the backup to be in the same location as the existing file (it's a quick fix). I want to create the file using File file = new File(PathName);
public void backUpOldPage(String oldContent) throws IOException{
// this.uri is a class variable with th...
I've read a few answers on here about reading Unicode files etc and most people point to UTF8-CPP or iconv.
None of the libraries that I found work for both ANSI and Unicode files, ideally I want one function which I pass a filename to and it will return the contents of that file and it won't matter what the encoding is, or is that not ...
Reading the javadoc on FileDesciptor's .sync() method, it is apparent that sync() is primarily concerned with committing any modified buffers back to the underlying storage. I.e., making sure that anything that your program has output will actually make it to the disk (or socket or what-have-you, but my question pertains mainly to disks)...
Hi,
I'm working on a piece of scientific software that is very cpu-intensive (its proc bound), but it needs to write data to disk fairly often (i/o bound).
I'm adding parallelization to this (OpenMP) and I'm wondering what the best way to address the write-to-disk needs.
There's no reason the simulation should wait on the HDD (which is...
I want to rewrite the contents of a file.
What I have thought of so far is this:
Save the file name
Delete the existing file
Create a new empty file with the same name
Write the desired content to the empty file
Is this the best way? Or is there a more direct way, that is, not having to delete and create files, but simply change the...