Hi there!!!
I am back with more problems, now in Java :)
What I am trying to do is to make an application to read and output a random line from a text file, but everything I know how to do is to output the whole lot. How can I access and output a RANDOM line from a file???
My current class is as follows:
package Talking;
import java.io.*;
public class Talking{
public static void main(String[] args) throws IOException{
File f;
f=new File("Talking.txt");
if(!f.exists()&& f.length()<0)
System.out.println("The specified file does not exist");
else{
FileInputStream finp=new FileInputStream(f);
byte b;
do{
b=(byte)finp.read();
System.out.print((char)b);
}
while(b!=-1);
finp.close();
}
}
}
The file, if anyone interested is something like
String 1
Line 2
Blablabla
The sound of the sea