Hi folks,
I'm reading a file into an array and trying to take out the numbers and put them as a double in an array of their own. And apparently my middle name must be "Error". From what I can tell the code is ok....at least theres nothing jumping out at me. Here it is in all it's glory.
import java.io.BufferedInputStream;
import java.io...
I'm trying to read contents of a game's map/model files into a program for the purposes of writing a small model viewer and testing out some DirectX features. The model/map file formats are chunked in nature, and I know the format of these files. I can easily read the files by parsing through the individual chunks, using an approach like...
Using htaccess I was able to hide the file extensions, making it /home instead of /home.html. However, for the homepage, I would like to hide the file name altogether, for example stackoverflow.com, instead of stackoverflow.com/home. How do I achieve this?
...
So here's the deal: I'm trying to open a file (from bytes), convert it to a string so I can mess with some metadata in the header, convert it back to bytes, and save it. The problem I'm running into right now is with this code. When I compare the string that's been converted back and forth (but not otherwise modified) to the original byt...
I have this python code for opening a .cfg file, writing to it and saving it:
import ConfigParser
def get_lock_file():
cf = ConfigParser.ConfigParser()
cf.read("svn.lock")
return cf
def save_lock_file(configurationParser):
cf = configurationParser
config_file = open('svn.lock', 'w')
...
On a Linux desktop (RHEL4) I want to extract a range of bytes (typically less than 1000) from within a large file (>1 Gig). I know the offset into the file and the size of the chunk.
I can write code to do this but is there a command line solution?
Ideally, something like:
magicprogram --offset 102567 --size 253 < input.binary > outpu...
How can I write from a file to shared memory using the Win32 API?
I have this code:
hFile = CreateFile("input.map",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
hMapFile = CreateFileMapping(hFile,
NULL,
PAGE_READWRITE,
0,
0,
TEXT("SharedObject"));
lpMapAddre...
Does File.deleteOnExit() guarantee that the file is deleted even if the JVM is killed prematurely?
...
I need to parse report files that are generated in an old version of the SpreadsheetML formats (See the HTML Header of the file below) in order to merge multiple single-page reports into a single tabbed workbook with all formatting and contents intact.
<HTML xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsof...
A.php:
<?php
...
?>
How to know the directory within itself?
EDIT
On windows,how to change "\" to "/"?
...
I am writing a desktop application under Windows in C++ MFC.
The application creates a index file, and writes information to it again and again.
If the application crashes, the next time the application starts it will delete the crashed index file and create a new one. I think in certain cases, the index file will be locked. It will be...
Hello
I have the following
//get the data as a string.
using (FileStream fs = File.Open(location, FileMode.Open))
using (StreamReader reader = new StreamReader(fs))
{
rawData = reader.ReadToEnd();
}
in the web config of the WCF host
<authentication mode="Windows"/>
<identity impersonate ="true"/>
however i get this error
...
I have this code which reads all the files from a directory.
File textFolder = new File("text_directory");
File [] texFiles = textFolder.listFiles( new FileFilter() {
public boolean accept( File file ) {
return file.getName().endsWith(".txt");
}
});
Works great. It fills the array with...
I have a small script, which is called daily by crontab using the following command:
/homedir/MyScript &> some_log.log
The problem with this method is that some_log.log is only created after MyScript finishes. I would like to flush the output of the program into the file while it's running so I could do things like
tail -f some_log....
Here is a simple piece of code:
import java.io.*;
public class Read {
public static void main(String[] args) {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
while(true)
{
String x = null;
try{
x = f.readLine();
}
catch (IOException e) {e.printStackTrace();}
System.out.println(x);
...
Hi,
I want to delete some files with python scripts (while using Windows). I have tried the following code:
>>>import os
>>> os.remove ('D:\new.docx')
but I am getting the following error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
os.remove ('D:\new.docx')
OSError: [Errno 22] Invalid argume...
Let's say we want to implement an equivalent of the PHP's file_get_content.
What is the best practice? (elegant and reliable)
Here are some proposition, are they correct?
using "with" statement:
def file_get_contents(filename):
with file(filename) as f:
s = f.read()
return s
using is using standard open safe?
def f...
How to write (or overwrite) the following contents:
<dependencies>
<dependency>
<groupId>ged.eprom</groupId>
<artifactId>epromx</artifactId>
<version>${version.to.set}</version>
<classifier>stubjava</classifier>
</dependency>
</dependencies>
into file called pom.xml in the current directory.
I have tried...
Provided that we know that all the file will be loaded in memory and we can afford it,
what are the drawbacks (if any) or limitations (if any) of loading an entire file (possibly a binary file) in a python variable. If this is technically possible, should this be avoided, and why ?
Regarding file size concerns, to what maximum size this...
Hello
I wonder if anyone can advise on a Java webapp question?
I have a set standard Java class which has methods to set and get values of a property file. These methods are used system wide and are called by servlets and non-servlet class methods alike.
But what I would like to do is to use a ServletContextListener to set the paths ...