Sunday, 26 December 2010

Contoh Program Java: Membaca Isi File Teks

import java.io.*;
public class baca_file {
public static void main(String arg[])
{
String file = "c://program1.txt"; //lokasi file
FileInputStream in = null;
try {
in = new FileInputStream(file);//
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
in.close();
}
} catch (IOException x) {
}
}
}

No comments:

Post a Comment