file-io

python-like Java IO library?

Java is not my main programming language so I might be asking the obvious. But is there a simple file-handling library in Java, like in python? For example I just want to say: File f = Open('file.txt', 'w') for(String line:f){ //do something with the line from file } Thanks! UPDATE: Well, the stackoverflow auto-accepted a wei...

explain this macro

#define __T(x) L ## x Found in code from one of the MFC source header file. It is mostly used for converting strings to ........ (I don't know what). If I am correct it converts strings to LPCTSTR...don't know what that type is either... I can't seem to convert char* into LPCTSTR. While MFC file handling, the following code will ...

Loading a file into a clob

Given a url pointing to a file hosted on the webserver, is it possible to read the contents of that url into a clob? And if so, how? ...

Is there a common way to access files, that works both on android and PC?

Hi, I'm writing an application that will ship in two versions: Android and PC version. Is there a simple way to access files from the shared code? Using java.io is simple, but I don't know how to access android resources or assets using it. And I can't write methods that operate on FileInputStreams instead, because some files contain r...

How to edit a .txt file in Java

i think i can use "Scanner" to read a .txt file but how can i write or even create a new text file? ...

How to write or append to text file using sql?

Hello, i need to call sqlcmd from stored procedure to export table to text file? ...

download large files using servlet

I am using Apache Tomcat Server 6 and Java 1.6 and am trying to write large mp3 files to the ServletOutputStream for a user to download. Files are ranging from a 50-750MB at the moment. The smaller files aren't causing too much of a problem but with the larger files it and getting socket exception broken pipe. File fileMp3 = new File(o...

How do I take a ByteArrayInputStream and have its contents saved as a file on the filesystem

I have an image which is in the form of a ByteArrayInputStream. I want to take this and make it something that I can save to a location in my filesystem. I've been going around in circles, could you please help me out. ...

[VB.Net] Does IO.File.Copy replicate files attributes?

Does the IO.File.Copy method preserve file attributes? Especially, if I have a write-protected file, will the copy be write-protected to? ...

Overwrite Content in PHP fwrite()

Is there any way you can overwrite a line in PHP. let me be a little more clearer using examples. My array array{ [DEVICE] => eth0, [IPADDR] => 192.168.0.2, [NETMASK] => 255.255.255.0, [NETWORK] => 192.168.0.0, [BROADCAST] => 255.255.255.255, [GATEWAY] => 192.168.0.1, [ONBOOT] => no } File im overwriting ...

Text file with each line represent a user, can I update a particular line?

If I have a text file like: 123, joe blow, USA Where the first values represent: USERID, NAME, COUNTRY If my file has 5000 rows, could I update a particular row somehow using C#? ...

Alternative Method for reading Files in C#?

Sometimes in reading data involving many names and figures reading line by line needs some serious concatenation work , is there any method that would allow me to read a specific data type? like the good old fscanf in C? Thanks Sara ...

Randomly select file in PHP

I'd like to use the 'include' keyword in php to randomly select a file from a folder and output the contents. How would I do this? Thanks. ...

Writing at the end of file

Hi, I'm working on a system that requires high file I/O performance (with C#). Basically, I'm filling up large files (~100MB) from the start of the file until the end of the file. Every ~5 seconds I'm adding ~5MB to the file (sequentially from the start of the file), on every bulk I'm flushing the stream. Every few minutes I need to upda...

Cross-platform and cross-process atomic int writes on file

Hello! I'm writing an application that will have to be able to handle many concurrent accesses to it, either by threads as by processes. So no mutex'es or locks should be applied to this. To make the use of locks go down to a minimum, I'm designing for the file to be "append-only", so all data is first appended to disk, and then the ad...

Files written with FileWriter are either 32 KB, 24 KB, 16 KB, ... big or empty

Hi, I read a file into a string, change the first line and then write this string into a new file. I do this through the following code (a little bit shortened): while(jspIterator.hasNext()){ String line = (String) jspIterator.next(); if (i == 0) { if (line.startsWith("bla...

How do I take advantage of Android's "Clear Cache" button

In Android's settings, in the "Manage Applications" activity when clicking on an app, the data is broken down into Application, Data, and cache. There is also a button to clear the cache. My app caches audio files and I would like the user to be able to clear the cache using this button. How do I store them so they get lumped in with ...

Where to put a textfile I want to use in eclipse?

hi there, I need to read a text file when I start my program. I'm using eclipse and started a new java project. In my project folder I got the "src" folder and the standard "JRE System Library" + staedteliste.txt... I just don't know where to put the text file. I literally tried every folder I could think off....I cannot use a "hard cod...

Modifying File while in use using Java

Hi all, I have this recurrent Java JAR program tasks that tries to modify a file every 60seconds. Problem is that if user is viewing the file than Java program will not be able to modify the file. I get the typical IOException. Anyone knows if there is a way in Java to modify a file currently in use? Or anyone knows what would be the...

VB.NET 2008, Windows 7 and saving files

Hello, We have to learn VB.NET for the semester, my experience lies mainly with C# - not that this should make a difference to this particular problem. I've used just about the most simple way to save a file using the .NET framework, but Windows 7 won't let me save the file anywhere (or anywhere that I have found yet). Here is the code...