file

How can I check the extension of a file using Perl?

To my perl script, a file is passed as an arguement. The file can be a .txt file or a .zip file containing the .txt file. I want to write code that looks something like this if ($file is a zip) { unzip $file $file =~ s/zip$/txt/; } One way to check the extension is to do a split on . and then match the last result in the arr...

Files java replacing characters

I have to check a text doc whether it exists or not and then i have to replace a letter in that say a to o. I have done the first part how to replace char class FDExists{ public static void main(String args[]){ File file=new File("trial.java"); boolean exists = file.exists(); if (!exists) { System.out.println("the ...

Remove Duplicate ID's?

I have a list of 50,000 ID's in a flat file and need to remove any duplicate ID's. Is there any efficient/recommended algorithm for my problem? Thanks. ...

how to do unit testing of functions writing files using python unittest

I have a python function that writes an output file to a disk. I want to write a unit test for it using python unittest module. How should I assert equality of files? I would like to get an error if the file content differs from the expected one + list of differences. As in the output of unix diff command. Is there any official/recomm...

How to create and read a file from spring web application running on JBoss?

I have a spring web application running on JBoss which is creating a csv file containing a report. The application must provide a link to the report when it finish its generation, and the user should be able to download it. I am thinking to write the file directly inside the war, so then we could read it from the web application. But I ...

How can I open a file only if it is not already open, in Perl?

If I have a subroutine that opens a file what is the best way to ensure it opens it only upon the first time the subrountine is called? I have this but not sure if its best practice: { my $count = 0; sub log_msg { my ($msg,$name) = @_; if ($count == 0) { my $log_file_name = "/tmp/" . $name; open my $log_fh,">",...

c# Drag and drop functionality

Hi there! In short, I want to make an application in which users can drag a file form their finder (mac), or their computer explorer (PC) to a location on my application, and then have that dragged file be loaded into the application. I don't have any kind of access to any drag and drop events (Supposedly), as I am using a rendering eng...

FileSystemWatcher problem in Windows 7

Hi, I wrote 2 applications: First one opens a text file, writes a sentence in it each few seconds (while keep it open) and flushes it (I've used StreamWriter class). Second one uses FileSystemWatcher to watch the file which other application is writing into. Obviously, the change event must be called each time the first application wri...

What's the cleanest way to fail gracefully when a file can't be opened in C++?

The program requires the file to run, but if for any myriad number of reasons it can't be found or isn't readable, etc - what's the cleanest way to fail out of the program? ...

how can i create a file on client side by JavaScript ?

i need to create a temp file to store user settings on the client side .it it possible to create a simple log file by JavaScript ? ...

Having Trouble Referencing Files in Android

I'm working in a group right now, writing an app that needs to be able to reference a file which is not written at runtime. Essentially, the file stores data which the app (a game) uses at certain points. I don't have any trouble saving files at runtime and then referencing those files, but for some reason, I'm having trouble referencin...

difficulties with python assignment

I am new to programing and am having difficulties writing a program dealing with files. The program is to read a file, calculate an employees pay and an updated YTD pay total. After calculations the program will write to a new file. This is what I have so far: empName = "" prevYTD = 0.0 payRate = 0.0 hoursWorked = 0.0 recordCount = 0 ...

how to efficiently work out where a file breaks from another earlier version?

I have a file that is constantly added to (a process beyond my control) and I capture that file every x seconds. I want to extract the new contents of the file (added between my previous capture) and work with it. The file unfortunately doesn't have anything to signify when it was last added to and I can't write to this file, so my only ...

doubt in file name

what is the difference b/w abstract pathname and pathname string. I came across these two when i was reading about string separator ...

Basic Python file searching and I/O

Hello, I'm trying to complete a simple task in Python and I'm new to the language (I'm C++). I hope someone might be able to point me in the right direction. Problem: I have an XML file (12mb) full of data and within the file there are start tags 'xmltag' and end tags '/xmltag' that represent the start and end of the data sections I w...

Read to right of specific symbol in file from Python

I'm going to separate over 1000 virus signatures and the virus names. I have them all in a text file, and would like to do this with python. Here is the format: virus=signature I need to be able to take 'virus' and write it to one file, then take 'signature' and write it to another. This is what I've tied so far: h = open("FILEW...

Get Line Number of certain phrase in file Python

I need to get the line number of a phrase in a text file. The phrase could be: the dog barked I need to open the file, search it for that phrase and print the line number. I'm using Python 2.6 on Windows XP This Is What I Have: o = open("C:/file.txt") j = o.read() if "the dog barked" in j: print "Found It" else: print "...

Load drop down menu in HTML from another file.

Is there anyway to load the drop down menu of an html from another file(A text file) ? I tried this and I guess it is not working. <form> <select name = "Name"> <!--#include virtual="options.txt" --> </select> </form> and inside options.txt <option value = "42a">42A</option> <option value = "42b">42B</option> <option value = "42c">...

how or with what to run *.jar file

Possible Duplicate: How to run a JAR file hi how or with what to run *.jar file ? can i get any tool for this (free if there is....) thank's in advance ...

jpg file rendering problem in IE?

we wrote CMS apps with asp.net. the user can attach file documents, pdfs to their forms and send to each other. the user can easily download the pdf and other documents but when they want to download jpg file their IE render the jpg file as a binary and show the binaries of jpg file? the IE didn't show the save as dialogue such as other ...