WeMo Connect

Setup Menus in Admin Panel

Read Text File

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

public class ReadTextFile {

static void ReadFile1(String filename) throws IOException

{

String everything;

BufferedReader br = new BufferedReader (new FileReader(filename));

try

{

StringBuilder sb = new StringBuilder();

String line = br.readLine();

while (line != null)

{

sb.append(line);

sb.append(System.lineSeparator());

line = br.readLine();

}

everything = sb.toString();

System.out.printf(“\n%s”, everything);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

finally

{

br.close();

}

}

public static void main(String[] args)  {

try {

ReadFile1(“example.txt”);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

January 9, 2015

0 Responses on Read Text File"

    Leave a Message

    Your email address will not be published. Required fields are marked *