Mark0198's Posts
Nairaland Forum › Mark0198's Profile › Mark0198's Posts
1 (of 1 pages)
let me know when ready. My name is Mark Makafa. |
The best and easiest way to open a file in java.
First of all, you have to import your classes by
using the *import* Method.
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
/* now your code goes below */
public class project {
private String path; /* the name of your path
directory */
public void recording(String file_name) { path =
file_name;
}
public String[] OpenFile() throws IOException
{FileReader file = new FileReader(path); /* your
path variable */ BufferedReader text = new
BufferedReader(file); /* the handler for your
( FileReader ) */int lines = 3;String[] textData =
new String[lines];for(int i=0;i<lines;i++)
{textData[i] = text.readLine();}text.close();return
textData;}
Now in your Main class you have to invoke the
project class in or you as a programmer will
definitely know what to do next. I think I have
tried.
Thank You. |
1 (of 1 pages)