package com.company; import java.io.FileWriter; import java.io.IOException; import java.util.Random; public class Main { public static void main(String[] args) throws IOException { int tab[][] = new int[10][10]; Random rand = new Random(); //zapełnienie tablicy for (int i = 0; i < tab.length; i++) { for (int j = 0; j < tab.length; j++) { tab[i][j] = rand.nextInt(100); } } //wyświetlenie tablicy for (int i = 0; i < tab.length; i++) { for (int j = 0; j < tab[i].length; j++) { System.out.print(tab[i][j] + " "); } System.out.println(); }//zapis do pliku String fileName = "plik.csv"; FileWriter fileWriter = null; try { fileWriter = new FileWriter(fileName); for (int i = 0; i < tab.length; i++) { for (int j = 0; j < tab.length; j++) { fileWriter.write(tab[i][j]); } } } catch (IOException ex) { System.out.println("Problez z dostępem do pliku"); } finally { if (fileWriter == null) { System.out.println("Problem"); } else { fileWriter.close(); } } } }