
I have created
FileInputStream fstream = new FileInputStream("E:\\TE MODULE\\Main Workspace\\OS PHASE 1\\input.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader bfr = new BufferedReader(new InputStreamReader(in));
for(int i=0;i<10;i++) {
String Str = bf.readline();
}
here is my 10th line. now i want to move to 1st line. what should i do ?

Here is a code that reads the first line of the text file.
import java.io.*;
class Modify
{
public static void main(String[] args) {
String line = "";
int lineNo;
try{
FileInputStream fstream = new FileInputStream("c:/emp.txt");
DataInputStream in = new DataInputStream(fstream);
String str="";
BufferedReader bfr = new BufferedReader(new InputStreamReader(in));
for (lineNo = 1; lineNo <=10; lineNo++) {
if (lineNo == 1) {
line = bfr.readLine();
}
str=bfr.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Line: " + line);
}
}

Here is another code that reads the file and moves back to the first line of the file using seek() method of RandomAccessFile class.
import java.io.*;
public class ReadAccessFile{
public static void main(String[] args) throws IOException{
try{
File f=new File("c:/emp.txt");
RandomAccessFile rand = new RandomAccessFile(f,"r");
int i=(int)rand.length();
rand.seek(0);
for(int ct = 0; ct < i; ct++){
byte b = rand.readByte();
System.out.print((char)b);
}
rand.seek(0);
rand.close();
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
}
}

Please don't use DataInputStream to read text. Unfortunately this example gets repeated again and again so can you remove it from your example.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.