file-io

Read All Text from file in Java

Does Java has a one line instruction to read to a text file, like what C# has? I mean, is there something equivalent to this in Java?: String data = System.IO.File.ReadAllText("path to file"); If not... what is the 'optimal way' to do this...? Edit: I prefer a way within Java standard libraries... I can not use 3rd party libraries....

How do I write to file in binary in C?

Why does this code not work as expected? #include <cstdio> int main() { char mona[] = "\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\x00\x01\x90" "\x00\x00\x02\x5d\x01\x03\x00\x00\x00\x26\xef\xb3\x78\x00\x00\x00\x45\x74\x45\x58" // <snip> "\x00\x49...

Pointer to FILE nulling itself without being used at all

Hello, in the following code when ran will produce a Segmentation Fault, due to a FILE* being passed to fclose which contains no address (NULL). I'm wondering why this is happening, the FILE* isn't being used what so over. The FILE* is named urandom and is passed to fclose in the main function. Thanks #include <stdio.h> #include <stdli...

fprintf keeps putting in extra characters I don't want. Can't I stop this?

Im trying to write out an image file that has the following structure: P5 //magic number 512 512 //dimension of image 255 //max value per pixel [Image Data.....] The standard says after max value there should be a whitespace or newline, then the image data. For whatever mysterious reason, the code below >always< adds in 2 c...

Accessing image files + file browsing in Android

Hi all, I'm using HTC Dream and trying to read the images stored in the "default" album folder of this phone. But I've yet to found out what's the folder path to those images file. When I mount the phone to my comp, some of the default images are in: /E0FD-1813/DCIM/ and the photos taken using the phone are stored in /E0FD-1813/DCIM...

Blackberry SDK with eclipse .jdp file not generated

I have using BlackBerry curve 8900 and SDK 4.6.1 but i can't get a .jdp file while build a application through eclipse.What should i change or include for that.But i can get all other files except .jdp .Please help me. Thanks in Advance.. ...

Working with files with anchors, which options are there for Java?

I am working with files (reading, writing and copying) in my Java application, java.io.File and commons-io were perfect for this kind of tasks. Right now, I can link to HTML in this way: Z:\an absolute\path\to\a\file.html But, I need to provide support for anchors too: Z:\an absolute\path\to\a\file.html#anchor keeping the system-i...

Read and copy file with EOF indicator in the middle

Hi, I used the code below to copy from one binary file to another, but the first file contains some EOF indicators (0xFF) as part of it, so the copy function actually copies the file until its first EOF indicator. For example: if my file is {0x01, 0x02, 0x03, 0xFF, 0x01, 0x02, 0xFF, 0xFF} then only {0x01, 0x02, 0x03} will be copied to ...

Check if a file is accessable on a shared network drive

Hi, I have a program that does different things my questions is related to access files in a network mapped drive or a shared folder the program can run a file msi/exe from the network (network mapped drive or a shared folder) the program can copy file from the network (network mapped drive or a shared folder) how I can check if the f...

open64() fails with ENOENT, even though the file exists

I'm trying to open a file that I just created with open64(). When I try to open the file though, the syscall fails with ENOENT. I know for a fact the file exists, because I just created it and ls shows it in the directory it is supposed to be in. When I try to open it with open(), it fails with EOVERFLOW, which is expected, but it also i...

C# Copy a file to another location with a different name

If certain conditions are met, I want to copy a file from one directory to another WITHOUT deleting the original file. I also want to set the name of the new file to a particular value. I am using C# and was using FileInfo class. While it does have CopyTo method. It does not give me the option to set the file name. And the MoveTo metho...

How do I read the number of files in a folder using Python?

How do I read the number of files in a specific folder using Python? Example code would be awesome! ...

Get the latest updated sub-directory

Am trying to find the latest sub-directory from a parent director. public static DirectoryInfo GetLatestSubDirectory(string parentDirPath) As of now the implementation is uses the bubble sort algorithm to find the latest by comparing the creation time. if (subDirInfo.CreationTimeUtc > latestSubDirInfo.CreationTimeUtc) Am wonderin...

Java: Outputting text file to Console

I'm attempting to output a text file to the console with Java. I was wondering what is the most efficient way of doing so? I've researched several methods however, it's difficult to discern which is the least performance impacted solution. Outputting a text file to the console would involve reading in each line in the file, then writi...

Group file to New Folder?

I have to copy files, make a new folder and then paste those files into the new folder so often. I wonder if we can make a batch file or vbscript file to perform this task? Just select the files and choose "Group to New Folder" from the context menu. That'll be awesome! ...

Write files without write permission via ASP.Net

Hello, I have created an ASP.Net application using .Net framework 4.0. I need to save an xml file on any location on same server (if file not already exists) and want to access then after always. But I dont want to set write permission to any folder. Is it possible to write a file to any location for Network service account without spe...

What is the difference between File.SetCreationTime() and File.SetCreationTimeUtc()

In particular, is there any difference between these two lines in terms of their outcomes: File.SetCreationTime("foo.txt", DateTime.UtcNow); File.SetCreationTimeUtc("foo.txt", DateTime.UtcNow); Perhaps File.SetCreationTimeUtc("foo.txt", DateTime.Now) is just another way of doing File.SetCreationTime("foo.txt", DateTime.UtcNow)? The s...

Cleaning up a String in Visual Basic - Those Annoying Rectangles

Can anyone give me some advice as to how to clean up a string in Visual Basic .NET? I'm creating a string as a report with line breaks. However, the string is built based off of screen scrapes from a TN3270 emulator. The string is saved successfully with all of the data I require, but those annoying rectangle symbols show up once I send ...

Mimic file IO in j2me midlet using RMS

I want to be able to record audio and save it to persistent storage in my j2me application. As I understand j2me does not expose the handset's file system, instead it wants the developer to use the RMS system. I understand the idea behind RMS but cannot seem to think of the best way to implement audio recording using it. I have a continu...

proper way to load resource file in VS 2008

Hi there, I have to load some binary resource files in C++ with Visual Studio 2008. But I haven't found a proper way to do with it. It seems that I can't add files with unknown file type directly into the project resource directory and read it. I could only read the file by opening it with the absolute location such as "c://...//...//fi...