Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,153,427 members, 7,819,555 topics. Date: Monday, 06 May 2024 at 06:04 PM |
Nairaland Forum / Science/Technology / Webmasters / Very Neat And Easy Method Of Using Java File Handler (419 Views)
Benefits Of Using Nigeria’s Domain Name, .ng / Advantages & Disadvantages Of Using Free Blogging Platform / What Are The Pros And Cons Of Using An Online Payment Gateway (2) (3) (4)
(1) (Reply)
Very Neat And Easy Method Of Using Java File Handler by mark0198: 4:06pm On Sep 06, 2015 |
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) (Reply)
The Power Of Self Employment / Post Your Health Or Medical Related Blog / Find Out Why Text Message Is Limited To 160 Characters
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 5 |