RandomAccessFile & FileInputStream

RandomAccessFile & FileInputStream

View Answers

June 25, 2009 at 12:12 PM

Hi Friend,

Unlike the input and output streams java.io. RandomAccessFile is used for both reading and writing the files with the use of three modes 'r','rw','rwd','rws'. A random access file treats with a large array of bytes stored in the file system and uses the file pointer to deal with the index of that array. This file pointer points the positions in the file where the reading or writing operation has to be done.

For more information,please visit the following links:

http://www.roseindia.net/java/example/java/io/RandAccessFile.shtml
http://www.roseindia.net/java/example/java/io/java-read-file-line-by-line.shtml

Thanks









Related Tutorials/Questions & Answers:
RandomAccessFile & FileInputStream - Java Beginners
RandomAccessFile & FileInputStream  I included a piece of code for reading data from a file using FileInputStream and RandomAccessFile class... when compared to FileInputStream. Also RandomAccessFile can read multiple
java RandomAccessFile
java RandomAccessFile  What is the difference between the File and RandomAccessFile classes
Advertisements
getResourceAsStream() vs FileInputStream
getResourceAsStream() vs FileInputStream  getResourceAsStream() vs FileInputStream
Java RandomAccessFile Example
Java RandomAccessFile Example Here you will learn about the RandomAccessFile... between 2 and 10 into text file. Then using the RandomAccessFile, we have...(); } } bw.close(); RandomAccessFile randomFile=new RandomAccessFile(f,"rw"
Java FileInputStream
Java FileInputStream In this section we will discuss about the Java IO FileInputStream. FileInputStream is a class provided in the java.io package... of FileInputStream class. FileInputStream's object can be created using following its
FILEOUTPUTSTREAM and FILEINPUTSTREAM - Java Beginners
FILEOUTPUTSTREAM and FILEINPUTSTREAM  Using FILEOUTPUTSTREAM and FILEINPUTSTREAM provide code that will write bytes to file and read them back.   Hi Friend, Please visit the following links: http
how to write file from FileInputStream
from FileInputStream. Please feel free to suggest or any reference website. Thanks,   Hi, For Write to file from FileInputStream in java you may use the FileInputStream class of java.io package. Using this class takes input
Java FileInputStream Example
Reading a file using FileInputStream... FileInputStream Java has Two types of streams- Byte & Characters. For reading... is used to read data from a file. The FileInputStream is the subclass
Java Write To File From FileInputStream
Java Write To File From FileInputStream In this tutorial you will learn how to write to file from FileInputStream. Write to file from FileInputStream in java you may use the FileInputStream class of java.io package. This class takes
How to use random access file
of RandomAccessFile class. RandomAccessFile allows read and write operations to any... manner. Unlike other  input and output streams, RandomAccessFile... operation with RandomAccessFile, then you have to create an instance with 'r' mode
java help - Java Beginners
java help  Write the code for a method named getFile that accepts a file name and returns a file created from the RandomAccessFile class. This method...[])throws IOException { FileInputStream fis=null; try{ fis = new FileInputStream
About BufferedReader
About BufferedReader   I have created FileInputStream fstream = new FileInputStream("E:\\TE MODULE\\Main Workspace\\OS PHASE 1\\input.txt...; try{ FileInputStream fstream = new
How display a image on servlet from file upload - JSP-Servlet
. This exception will be thrown by the FileInputStream, FileOutputStream, and RandomAccessFile constructors when a file with the specified pathname does not exist
Serializable Interface
Java I\O file
Java I\O file  What is the difference between the File and RandomAccessFile classes
java - Java Beginners
java  public static void Trial(File file) { RandomAccessFile input = null; whats wrong in it? String line = null; try { input = new RandomAccessFile(file, "r"); while ((line
IO Streams in Java with Examples
File FileInputStream... PushbackReader RandomAccessFile
RANDOM ACCESS FILE CONCEPT
the RandomAccessFile class
java io
java io  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits
File Handling In Java
, FileInputStream, FileOutputStream, ByteArrayInputStream, ByteArrayOutputStream, PrintStream, RandomAccessfile etc.ADS_TO_REPLACE_6 Methods defined by InputStream : read
Unhandled Exception in Thread
. This exception is thrown by the FileInputStream, FileOutputStream, and RandomAccessFile constructors.ADS_TO_REPLACE_4 Java.lang.illegalargumentException
Java file seek
is RandomAccessFile. This class has two arguments, one of which is a File object... example, we have created an object of RandomAccessFile class and pass file object...- This method of RandomAccessFile writes the string into the file. Here is the code
IOException - Java Beginners
("DemoRandomAccessFile.out"); RandomAccessFile raf = new RandomAccessFile(file, "rw...("DemoRandomAccessFile.out"); RandomAccessFile raf = new RandomAccessFile(file, "rw"); raf.seek
SHA256 of a file
{ RandomAccessFile file = new RandomAccessFile("data.txt", "r"); MessageDigest md... Exception{ int by = 16384; try { RandomAccessFile file = new RandomAccessFile("data.txt", "r"); MessageDigest md = MessageDigest.getInstance
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to write the details of an employee to a file. Details such as year of joining, department code, employee name and salary should be included. You must use RandomAccessFile
How display a image on servlet from file upload - JSP-Servlet
by the FileInputStream, FileOutputStream, and RandomAccessFile constructors when a file
JSP - Java Server Faces Questions
JSP  how to set a lock to the folder by using jsp?  Hi friend, Code to help in solving the problem. FileInputStream in = new FileInputStream(file) { try { java.nio.channels.FileLock lock
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class...) throws Exception { FileInputStream in = new FileInputStream("c:/hello.txt
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class...) throws Exception { FileInputStream in = new FileInputStream("c:/hello.txt
Java file SequentialInputStream
of FileInputStream to parse three different files and then add these to the vector...[] args) throws Exception { FileInputStream f1 = new FileInputStream("C:/output.txt"); FileInputStream f2 = new FileInputStream("C:/file.txt
File Handling - Java Beginners
{ File f; f= new File(name); if(f.exists()){ RandomAccessFile rand = new RandomAccessFile(name,"rw"); System.out.println
Classes and Interfaces of the I/O Streams
a FileInputStream and FileOutputStream.  FileInputStream....  RandomAccessFile It supports both reading and writing to a random access
Java programming help with files - Java Beginners
")){ RandomAccessFile rand = new RandomAccessFile("American.txt","rw"); rand.writeBytes(data); rand.close(); } else{ RandomAccessFile rand = new RandomAccessFile("NonAmerican.txt","rw"); rand.writeBytes(data
input output
This class uses for create a FileInputStream and FileOutputStream. FileInputStream It contains the input byte from a file.... RandomAccessFile It supports both reading and writing
Stream Cipher
, paramSpec2); FileInputStream fis = new FileInputStream(inputFile); FileOutputStream..._MODE, key2, paramSpec2); FileInputStream fis = new FileInputStream(inputFile
SCJP Module-10 Question-8
Re-arrange the code for reading a text file. FileInputStream fstream = (1) Place code here (1) Place code here = new DataInputStream(fstream... sentences for proper execution of above code.(X) new FileInputStream("
struts2
struts2  how to read properties file in jsp of struts2   Hi, You can use the Properties class of Java in your action class.ADS_TO_REPLACE_1 Properties pro = new Properties(); FileInputStream in = new FileInputStream(f
File Handling - Java Beginners
File Handling  Q. Write a java prg which accepts a list of existing... args[]) { FileInputStream fin1,fin2,fin3; FileOutputStream fout2,fout3; try { try { fin1=new FileInputStream(args[0]); fout2=new
Java file lock
{ RandomAccessFile file = new RandomAccessFile("C:/file.txt", "rw"); FileChannel
Java display file content in hexadecimal format
in hexadecimal format. For this we have used FileInputStream class to open a file... Exception { FileInputStream fis = new FileInputStream("C:/data.txt"); int i
Java Write GZIP File Example
"; FileInputStream inputStream = new FileInputStream(fileToCompress); /* Creating... and FileInputStream classes */ inputStream.close(); outputStream.close
Using throw keyword in exception handling in Core Java
ExcepHandling1 {ADS_TO_REPLACE_2 public static FileInputStream file1(String fileName) { FileInputStream fileInStrm = null; try {ADS_TO_REPLACE_3 fileInStrm = new FileInputStream(fileName); } catch (FileNotFoundException ex
Question about "Insert text file data into Database"
Question about "Insert text file data into Database"  Hey I was reading the tutorial "Insert text file data into Database", (awesome btw), and noticed that both a FileInputStream, a DataInputStream and a BufferedReader
JAVA Objectives Question?
the FileInputStream that opens a file that contains the name of the user's favorite book... have used FileInputStream and FileOutputStream for I/O operations. import...(""); FileInputStream fis=new FileInputStream(f); while ((ch = fis.read()) != -1
Getting File path error - JSP-Servlet
(); FileInputStream f = new FileInputStream(str); serviceProp.load(f); f.close
file reading - Swing AWT
{ file = new File("c:\\New.doc"); FileInputStream fis=new FileInputStream
read a file
://Try.txt"); try { FileInputStream fin = new FileInputStream(file
File not found
); FileInputStream in1 = new FileInputStream(svefile); int len
File not found
); FileInputStream in1 = new FileInputStream(svefile); int len

Ads