package a;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
*
* @author indha
*/
public class bacafile {
public static void main(String args[]){
FileInputStream input=null;
int data; //membuka file
try{
input=new FileInputStream("d:/contoh.txt");
}catch(FileNotFoundException fn){
System.out.println("file tdk ditemukan");
}
//membaca data dari dalam file
try{
while((data=input.read())!=-1){
System.out.print((char)data);
}
}catch(IOException in){
System.out.println(in.getMessage());
}//menutup file
try{
input.close();
}catch(IOException e){}
}
}
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
*
* @author indha
*/
public class bacafile {
public static void main(String args[]){
FileInputStream input=null;
int data; //membuka file
try{
input=new FileInputStream("d:/contoh.txt");
}catch(FileNotFoundException fn){
System.out.println("file tdk ditemukan");
}
//membaca data dari dalam file
try{
while((data=input.read())!=-1){
System.out.print((char)data);
}
}catch(IOException in){
System.out.println(in.getMessage());
}//menutup file
try{
input.close();
}catch(IOException e){}
}
}
21.38
0 komentar:
Posting Komentar