file-io

C# File.ReadAllLines not breaking on line feeds

Hello, I have an application that I am building that needs to modify a configuration file. My problem is that I am not able to read the file in line by line. I keep geeting the the entire file as a single string. string ConfigTemplate = AEBuildsSPFolderName + "\Template_BuildReleaseScript.Config"; string[] fileSourceLines = File.Rea...

Local File-type Datastore for Winforms

Hi there! I hope my title is not misleading, but what I'm looking for is a file-type datastore for a Winforms app (.NET 3.5) that will allow me to: store/retrieve strings and decimal numbers (only); open and save it to a file with a custom extension (like: *.abc); and have some relational data mapping. Basically, the application sh...

File being used by another process after using File.Create()

Hi All, I'm trying to detect if a file exists at runtime, if not, create it. However I'm getting a 'The process cannot access the file 'myfile.ext' because it is being used by another process.' error when I try to write to it. string filePath = string.Format(@"{0}\M{1}.dat", ConfigurationManager.AppSettings["DirectoryPath"], costCent...

Reading a text file in Java

I want to read a text file containing space sepearted values. Values are integers. How can I read it and put it in an array list? Here is an example of contents of the text file: 1 62 4 55 5 6 77 I want to have it in an arraylist as [1, 62, 4, 55, 5, 6, 77]. How can I do it in Java? ...

May the FileInputStream.available foolish me?

This FileInputStream.available() javadoc says: Returns an estimate of the number of remaining bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of...

Blackberry read local properties file in project

Hi, I have a config.properties file at the root of my blackberry project (same place as Blackberry_App_Descriptor.xml file), and I try to access the file to read and write into it. See below my class: public class Configuration { private String file; private String fileName; public Configuration(String pathToFile) { this.fileName =...

Seeking to a line in a file in g++

Is there a way that I can seek to a certain line in a file to read or write data? Let's say I want to write some data starting on the 10th line in a text file. There might be some data already in the first few lines, or the file could even be empty. Is there a way I can seek directly to the line I want without having to worry about wh...

Equivalent of freopen in Java

Please suggest a method to obtain a similar behaviour in Java as when we do freopen("filename","r",stdin) OR freopen("filename","w",stdout) in C. ...

Enter custom file name to be read ?

Hello, I want to allow users to type the name of any .txt file to be read/written. This is my code : printf("Enter .txt file name\n"); scanf("%s",&fname); FILE *inputf; inputf=fopen(&fname,"w"); Problem is this method does not work (having &fname) as a parameter. I can imagine its because C needs "filename.txt" for it work...

Scan file contents into an array of a structure.

Hello, I have a structure in my program that contains a particular array. I want to scan a random file with numbers and put the contents into that array. This is my code : ( NOTE : This is a sample from a bigger program, so I need the structure and arrays as declared ) The contents of the file are basically : 5 4 3 2 5 3 4 2 #include...

How to convert binary read/write to non-binary read/write in C++

I have some C++ code from somewhere that reads and writes data in binary format. I want to see what it's reading and writing in the file, so I want to convert it's binary read and write to non-binary read and write. Also, when I convert the binary write to non-binary write, I want it to still be able to read in the information correctly...

Reading and writing to files simultaneously?

Moved the question here. Suppose, I want to store 1,000,000,000 integers and cannot use my memory. I would use a file(which can easily handle so much data ). How can I let it read and write and the same time. Using fstream file("file.txt', ios::out | ios::in ); doesn't create a file, in the first place. But supposing the file exists, I a...

Write to a file stream returned from getResourceAsStream()

I am getting a a InputStream from getResourceAsStream(), and I managed to read from the file by passing the returned InputStream to a BufferedReader. Is there any way I can write to the file as well? ...

Accessing a file (for writing) from a JBoss Web Service

Let's say I have this structure of my Java Web Application: TheProject -- [Web Pages] -- -- abc.txt -- -- index.jsp -- [Source Packages] -- -- [wservices] -- -- -- WS.java WS.java is my Web Service, which is situated in a wservices package. Now from this service, I need to access the abc.txt file and write to it. These a...

Batch backup a harddrive without modifying access times C#

I'm trying to write a simple program that will backup my flash drive. I want it to work automatically and silently in the background, and I also want it to be as quick as possible. The thing is, resetting all the access times is useless to me, and something I want to avoid. I know I can read the access times and set them back, but I bet ...

Split file with PHP and generate contents

How do I split the content below into separate files without the placeholder tags. I'd also like to take the text inside the placeholder tags and place them inside a new contents file. <div class='placeholder'>The First Chapter</div> This is some text. <div class='placeholder'>The Second Chapter</div> This is some more text. <div c...

how to read an arraylist from a txt file in java?

How to read an arraylist from a txt file in java? My arraylist is of the form: public class Account { String username; String password; } I managed to put some "Accounts" in the a txt file, but now I don't know how to read them. This is how my arraylist looks in the txt file: username1 password1 | username2 password2 | etc ...

How to skip the first line when fscanning a .txt file ?

Hello there, I am using C and my knowledge is very basic. I want to scan a file and get the contents after the first or second line only ... I tried : fscanf(pointer,"\n",&(*struct).test[i][j]); But this syntax simply starts from the first line =\ How is this possible ? Thanks. ...

One row is skipped each time the program scans a matrix from file !

Hello there, I had this code working yesterday, but it seems like I edited it a bit and lost the working version. I cant get this to work anymore. I basically want to scan a matrix from a .txt file. But each time it scans the first row, the second one is skipped, and it reads the third instead :( Here is my code : for(i=0;i<=test->ro...

Using C++ to find out how many lines are in a text file

My C++ program needs to know how many lines are in a certain text file. I could do it with getline() and a while-loop, but is there a better way? ...