Reading the Data from the Files Using Java.

With the help of the following code you can read the data from the .txt file or the Simple TEXT file.

To make this code working i have used this code with the Applet so that With the Help of Text area you can easily view the data that reside in to the Text file and the code is as follows.

//Import all the Things

import java.applet.*;
import java.awt.TextArea;
//Declare the Class nd Extends to the apllet
public class MyApplet extends Applet {
//Declare Text area to get the Content to be Displayed
TextArea t1;
public void init()
t1 = new TextArea();
//we have used the readfile function which will deal with the File, you can define the path too
//Definition of the Function that we have used that will take the name of the file as the argument
public void readFile(String f) {
try {
String aLine = “”;
//getting the file
URL source = new URL(getCodeBase(), f);
BufferedReader br = new BufferedReader(new InputStreamReader(source.openStream()));
//reading the fill untill it gets over
while((aLine = br.readLine())!= null) {
//Appending the data to the Textarea
// This will display in the console too
catch(Exception e) {
Output is as follows..
File Reader
File Reader
Thus how you can read the File in the Applet ..
Don’t you think its so simple..?
Hmm Good try this and if any problem then Tell me.

5 thoughts on “Reading the Data from the Files Using Java.

  1. hello!This was a really marvelous topic!
    I come from roma, I was fortunate to search your Topics in digg
    Also I get much in your website really thanks very much i will come daily

    1. hie there.. Thanks for your comments.. and ya i ll be also uploading the post regarding the speech recognization too very soon and if you have any query then feel free to ask me dear.. Ok Bye Bye C ya Take care. 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s