🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / Java / DOSYAYI PARÇALAYARAK DİZİYE ATAR SATIR VE SUTUN OLARAK

 

1-) Java - DOSYAYI PARÇALAYARAK DİZİYE ATAR SATIR VE SUTUN OLARAK

 

public int dizi[][] = new int[10][10];

 

int j = 0;

 

String[] parcala = null;

 

private void formWindowOpened(java.awt.event.WindowEvent evt) {

 

try {

 

FileInputStream fr = new FileInputStream("dosya.txt");

 

InputStreamReader isr = new InputStreamReader(fr, Charset.forName("ISO-8859-9"));

 

BufferedReader br = new BufferedReader(isr);

 

String line = br.readLine();

 

while (line != null) {

 

parcala = line.split(" ");

 

for (int i = 0; i < parcala.length; i++) {

 

dizi[j][i] = Integer.parseInt(parcala[i]); }

 

j++;

 

line = br.readLine(); } }

 

catch (IOException ee) {

 

JOptionPane.showMessageDialog(null, "dosya hatası", ee.getMessage(), JOptionPane.ERROR_MESSAGE); }

 

catch (NumberFormatException et) { JOptionPane.showMessageDialog(null, "dosya okuma hatası", et.getMessage(), JOptionPane.ERROR_MESSAGE); } }

 

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

 

for (int i = 0; i < parcala.length; i++) {

 

for (int j = 0; j < parcala.length; j++) {

 

System.out.print(dizi[i][j]+" "); }

 

System.out.println(""); } }

 2021 Ocak 18 Pazartesi
 457