Java Programing laungage

Java Input Output Projects

Java I/O Project 1

Java Input Output Examples

Java Input Output Examples

Example of the Random Access File

There are shown the Example of the Random Access File.

Previous Home Next
adplus-dvertising

import java.io.*;
public class Readfile{
public static void main(String[] args) throws IOException{
bufferReader br=new BufferReader(InputStreamReader(System.in));
System.out.println("Enter the file");
String str=br.readLine();
File file= new File(str);
if(!file.Exists()){
System.out.println("File does not Exist ");
System.exit(0);}
try{
RandomAccessFile raf=new RandomAccessFile(File,"r");
int i=(int)raf.Length;
System.out.println("the length is:"+ i);
raf.seek(0);
for(int k=0;k<i;k++){
byte A=raf.readByte();
System.out.println((char)A);}
raf.Close();
} catch(Exception e) { System.out.println(e.getMessage()); } } }
Previous Home Next