package readfile;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author nurhak.kaya
*/
public class ReadFile {
public static void main(String[] args) {
File file = new File("text.txt");
StringBuffer sb = new StringBuffer();
BufferedReader br = null;
String text = null;
try {
br = new BufferedReader(new FileReader(file));
while ((text = br.readLine()) != null) {
sb.append(text).append(
System.getProperty("line.separator"));
System.out.println(text);
}
} catch (Exception e) {
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
Logger.getLogger(ReadFile.class.getName()).log(
Level.SEVERE, null, ex);
}
}
}
}
}
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author nurhak.kaya
*/
public class ReadFile {
public static void main(String[] args) {
File file = new File("text.txt");
StringBuffer sb = new StringBuffer();
BufferedReader br = null;
String text = null;
try {
br = new BufferedReader(new FileReader(file));
while ((text = br.readLine()) != null) {
sb.append(text).append(
System.getProperty("line.separator"));
System.out.println(text);
}
} catch (Exception e) {
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
Logger.getLogger(ReadFile.class.getName()).log(
Level.SEVERE, null, ex);
}
}
}
}
}
Hayatın özünü kodlara yazıp yansıttığınız bu veciz blogunuz hayırlı uğurlu olsun...muhabbetle
ReplyDelete