random « API « Java I/O Q&A





1. Any code tips for speeding up random reads from a Java FileChannel?    stackoverflow.com

I have a large (3Gb) binary file of doubles which I access (more or less) randomly during an iterative algorithm I have written for clustering data. Each iteration does about ...

2. Random Access of file    stackoverflow.com

Input = Line number. Output = Replace the line at given line number by new line. example = a.txt

aaaa
bbbb
cccc
input= line number=3 replace with dddd output
aaaa
bbbb
dddd

3. is it possible to access objects randomly in java?    stackoverflow.com

basically I have a file of String Objects. I used Java ObjectOutputStream to store the objects. Is it possible to access the objects(Strings) randomly, say if I want to ...

4. BufferedInputStream not working with random seeks in file    stackoverflow.com

The write procedure to my file was as follows (in the mode which I call non-clustered)

  1. Write an object to the current position of the file. Note the ...

5. randomly reading from the stream ??    coderanch.com

6. Random Access Files    coderanch.com

I've just started using random access files and need to know what i'm doing wrong. I've made a test program (just to learn how to work with them) but it dosn't work properlly. The first part of the program reads in names entered by the user and should work like this: read in name from user write to file repeat until ...

7. Random Access Files    coderanch.com

8. Random Access Files    coderanch.com

I've just started using random access files and need to know what i'm doing wrong. I've made a test program (just to learn how to work with them) but it dosn't work properlly. The first part of the program reads in names entered by the user and should work like this: read in name from user write to file repeat until ...

9. How to randomly access a file    coderanch.com

After creating a file reference, I'd like to read a header and then at various times seek to various positions (based upon the contents of the header). Using reset() fails to work as apparently new InputStream( new File( filename ) ) doesn't implement marking. Short of destroying the input stream and re-creating it how is this typically handled? Thanks,





10. Random Access Files    coderanch.com

Hi, I have a question regarding the "best" way to work with a RandomAccessFile. I have a program that works, but which is probably rather crude, and so I am wanting to find out if there is a more efficient and elegant way to achieve what I'm doing. My program writes records (a String and an int) to a RandomAccessFile using ...

11. Deleting Random Access Files    coderanch.com

12. Random stream cut off    coderanch.com

Hey all, I have designed a class, specifically designed for unix systems which dumps a specified number of bytes from the /dev/random block device to a specified binary file. Unfortunately I discovered that while java will read and copy 128 bytes of data, after that, the stream puts out zeros. IE: If I request a 256 byte file, it will give ...

13. random access files    coderanch.com

I am writing a student databse program in java files. I have some serious problems. I am able to insert the data correctly into the file and can not retrive the specified data item only first colum needed,more over how to update a recoed and delete a paeticular student recoed 4rom a random access files. I use only 4 fields for ...

15. Random Access Files trouble    forums.oracle.com

Yes, I agree, I didn't look at much of that code because there's way too much of it to read. This data you're expecting something (an applet?) to display, is it actually in the file? If so then you could forget about showing us the code that put the data in the file. But if not then you should start looking ...

16. Using Random Access Files    forums.oracle.com





17. Random access of ObjectOutputStream    forums.oracle.com

18. InputStream.read() returning random results?    forums.oracle.com

Maybe I'm missing something, but where exactly do you check the return value of in.read() for -1? That's what you'll get when you reached the end of the stream. I see 3 read() calls in your code and each one either masks a possible -1 value by doing "& 0xff" or ignores the return value entirely! So I'm have a pretty ...

19. Imge from Random AccesFile or FileReader    forums.oracle.com

java.io.Reader and all of its subclasses (which includes FileReader) are meant to be used to do text related IO operations. Instead of a reader use the InputStream equivalent (in this case FileInputStream and maybe wrap that one in BufferedInputStream). See the [Java IO tutorial|http://java.sun.com/docs/books/tutorial/essential/io/] for basic information on how to do IO.

20. RandomAccessFile...appending randomly    forums.oracle.com

21. do random access files work with the JAR file format?    forums.oracle.com

Hi everyone, I'm writing a little program (using BlueJ) and i need to make a JAR file of that program to run it independently of BlueJ. In one of the classes in the program, i have a random access file, which contans a list of records. When i create the JAR file and run it, i can not access the random ...

22. Using Random Access Files    forums.oracle.com

Right so, my problem: When i want to add in a string, i have to use writeUTF() right? i'm not sure on either how to make a "blank" area for a string, since it could be of variable bytes. i've tried experimenting with a few things like in that loop there putting myFile.writeUTF(" "); but that obviously doesn't work. so basically ...

23. Random Access Files    forums.oracle.com

I am trying to find the total number of records in a random access file Is there any way by which I could have a value and increment that each time record is created? But even if i do that; as soon as application ends the value would be deleted. So is there any way by which i could use record ...

24. Random Access on a file    forums.oracle.com

Hello everybody, I have a text file which conatins m*n 2d matrix m and n can be greater than 20000 also. Aprt from this matrix it can also have comments in between like this "# This is a comment". I want to have random access in that file. I know this can be achieved using RandomAccessFile class. But can anyone tell ...

25. Random Access Files    forums.oracle.com

That was exactly the problem! Thanks a lot for the reply. I was overlooking the problem thinking it was larger. I know the code it not very pretty but I am still learning the language in school. Would you prefer passing it by reference to avoid a call to the copy constructor or how? Not pass the file at all? Thanks. ...