I understand that both Java and Perl try quite hard to find a one-size-fits all default buffer size when reading in files, but I find their choices to be increasingly antiquated, and am having a problem changing the default choice when it comes to Perl.
In the case of Perl, which I believe uses 8K buffers by default, similar to Java's ...
I read that file locking on network files isn't very reliable.
I'm using those LockFile/LockFileEx/UnlockFile win32-api functions for range-locks. Does anyone have some experience of using those functions on files living on a network-share?
...
I have a button that I want to disable as long as there isn't a specific number of files in a directory.
Is there some kind of listener that notifies me at the moment a file is created or deleted in a directory?
...
We have a simple Webapp running on two Tomcat instances behind Apache (a Tomcat HA setup using mod_proxy_balancer and mod_proxy_ajp). The role of the webapp is to write incoming request data to a log file.
Given that each tomcat instance is running in it's own JVM, how should we implement the log file writing?
It would be excellent if ...
Given a text file, how would I go about reading an arbitrary line and nothing else in the file?
Say, I have a file test.txt. How would I go about reading line number 15 in the file?
All I've seen is stuff involving storing the entire text file as a String array and then using the value of the line number as the number of the String to...
if i have a file contains 4000 bytes, can i have 4 threads read from the file at same time? and each thread access a different section of the file.
thread 1 read 0-999, thread 2 read 1000 - 2999, etc.
please give an example in java.
...
Every time I write to the text file I will lose the original data, how can I read the file and enter the data in the empty line or the next line which is empty?
public void writeToFile()
{
try
{
output = new Formatter(myFile);
}
catch(SecurityException securityException)
{
System.err.println("E...
Hi,
I'd need to read and process somewhat large file with Java and I'd like to know, if there is some sensible way to protect the file that it wouldn't be overwritten by other processes while I'm reading & processing it?
That is, some way to make it read-only, keep it "open" or something...
This would be done in Windows environment.
...
The official documentation doesn't specify. I understand EOFError means "End of file error", but what exactly does that mean? If a file reader reaches the end of a file, that doesn't sound like an error to me.
...
class __init__:
path = "articles/"
files = os.listdir(path)
files.reverse()
def iterate(Files, Path):
def handleXml(content):
months = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
parse = re.compile('<(.*?)>(.*?)<(...
What is the recommended approach to get the best performance when we need to create text files bigger than 10MB.
There are multiple sections in the code that need to write stuff to a single file. This means a lot of text lines.
Option #1: (This logic will be called at several times)
Create a StreamWriter instance
Write some lines (a...
I'm quite new to python and GAE, can anyone please provide some help/sample code for doing the following simple task? I managed to read a simple file and output it as a webpage but I need some slightly more complicated logic. Here is the pseudo code:
open file;
for each line in file {
store first line as album title;
for eac...
Learning Ruby. I'm looking for a script to search a file (or list of files) for a pattern and, if found, replace that pattern with a given value.
Thoughts?
...
Simple question really...
How can I copy a ReadOnly file?
When running a debug build of my very simple Windows Forms app, I'm getting the UnauthoriazedAccess Exception when trying to copy a read-only file from one directory to another:
FileInfo newFile = new FileInfo(fileName);
File.Copy(newFile.FullName, Path.Combine(destinationDirPa...
I am generating a file on the server and I do not want to write it to disk but instead return it to the client via a web service. What recommendations would you have to do this?
...
I have an MS Access database that has Full paths to files in a table. We are moving all the file to a different location. I need to update the database. I'm using C# to do this. When I search for the file path stored in access it searches for 'K:\PDFFiles\myPDF.pdf' instead of 'K:\PDFFiles\myPDF.pdf' and does not find a match. So, my que...
Say I have a big file in one directory and an older version of it in another. Is it somehow possible to update the older version with only the changes in the new one? So that I would copy only a small fraction from one place to another. Would have to work for both text and binary files.
Not sure if this is possible though, but curious t...
What is the most efficient way of retrieving and replacing the last line of a text file (in Java 1.4) that could potentially contain millions of lines? Code examples I have seen so far have needed to iterate through the entire file line-by-line before determining if the last line was reached.
A similar question was asked about replacing...
Hi,
How do I check if the following statement in my C# executed correctly?
StreamReader sr = new StreamReader(Path_To_File);
...
I write application in Java using SWT. I would like to create unique file name. But I do not want create it on hard drive. Additional functionality: I want to create unique file name in specify folder.
public String getUniqueFileName(String directory, String extension) {
//create unique file name
}
...