Dr. GÜRAY SONUGÜR

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

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

Array.txt İndirebilirsiniz!

import java.io.*;
public class IO_Okuma2_Ders_2 {

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

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

String[] line = new String[5];

int i=0;
String str;

while((str=line[i]=in.readLine())!=null)
{
//System.out.println(“Deger[” +i + “]: ” + line[i]);

if (line[i].startsWith(“Müh”)) {
System.out.println(“Deger[” +i + “]: ” + line[i] + i +”. satırda bulundu”);
i++;
}
}
f.close();

}

}