Dr. GÜRAY SONUGÜR

Dr. Öğr. Üyesi Güray SONUGÜR – Öğrenci Bilgi Paylaşım Platformu

Text Dosyadan Okuyup Diziye Yazma (For döngüsü)

Array.txt

import java.io.*;
public class IO_Okuma1_Ders {

public static void main(String[] args) throws IOException {

FileReader f = new FileReader(“Array.txt”);
BufferedReader in = new BufferedReader(f);

String[] line = new String[4];

for (int i = 0; i < 4; i++) {

line[i]= in.readLine();

if (line[i].startsWith(“Müh”)==false) {
System.out.println(“Değer:” + line[i] + “Aranan değer bulundu ” + i+”. satırda”);
}

// System.out.println(“Deger[” +i+”] ” + line[i]);
}
f.close();
System.out.println(“Dosya Kapandı!!”);

}

}