hi all. I have just started learning java after C + +.
but so far nothing is clear. especially the work with classes.
tell me please how to open a file for reading or writing? it is desirable to provide the code completely.
Thanks. sorry for bad english.
upd: I started to learn java hour ago, but has not yet written a working program....
I have a collection of files with fully qualified paths (root/test/thing1/thing2/file.txt). I want to foreach over this collection and drop the file into the location defined in the path, however, if certain directories don't exist, I want them to great created automatically. My program has a default "drop location", such as z:/. The ...
Hi,
Deleting a particular line/certain bytes from a file is very inefficient as there is a lot of reading and writing(re-writing) to be done. Is there anyway we can minimize work in such a process? Imagine if an entire file is a set of linked lists and as a user we know the structure of these linked lists then wouldn't it be wonderful a...
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyBytes1 {
public static void main(String[] args) throws IOException {
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream("c:\\aaa.txt");
out ...
What will happen if files are accessed concurrently from different processes/threads?
I understand there is no standard way of locking a file, only os specific functions.
In my case files will be read often and written seldom.
Now if A open a file for reading (ifstream) and starts reading chunks. And B opens the same file for writing (o...
class Patmatch {
static String strLine="";
public static void main(String [] args) {
try {
FileInputStream fstream = new FileInputStream("c://abc.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br1 = new BufferedReader(new InputStreamReader(in));
while ((strLine = b...
Ok I have something like this:
struct dirent *dp;
DIR *dir;
char fullname[MAXPATHLEN];
char** tmp_paths = argv[1]; //Not the exact code but you get the idea.
...
while ((dp = readdir(dir)) != NULL)
{
struct stat stat_buffer;
sprintf(fullname, "%s/%s", *tmp_paths, dp->d_name);
if (stat(fullname, &stat_buffer) != 0)
...
Ok, this should be easy...
I'm new to groovy and I'm looking to implement the following logic:
def testFiles = findAllTestFiles();
So far, I've come up with the code below which successfully prints all files names. However, instead of printing, I just need to put them into a collection. Of course, I could do this the old java way: ...
Usually with my output I am writing it to the Transcript with...
Transcript show:
How does one write the output to a file instead?
...
Hello everyone,
I have a csv file with records being sorted on the first field. I managed to generate a function that does binary search through that file, using fseek for random access through file.
However, this is still a pretty slow process, since when I seek some file position, I actually need to look left, looking for \n charact...
Hi all, I am having a runtime error that I can not for the life of me figure out. My program almost does what I want it to, but there are some corrupted characters that print out as gibberish. The program is supposed to take in a text file that represents a forest of trees, build the forest of trees, then traverse the forest to print i...