Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Test;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.Scanner;
- public class Test {
- public static void main(String[] args) {
- String filename = "data.txt";
- try {
- FileReader infile = new FileReader(filename);
- Scanner sc = new Scanner(infile);
- // Tabel dimensies
- int rij = sc.nextInt();
- System.out.println("Rij: " + rij);
- int kolom = sc.nextInt();
- System.out.println("Kolom: " + kolom);
- int[][] table = new int[rij][kolom];
- for (int i = 0; i < rij; i++) {
- for (int j = 0; j < kolom; j++) {
- table[i][j] = sc.nextInt();
- }
- }
- for (int i = 0; i < rij; i++) {
- for (int j = 0; j < kolom; j++) {
- System.out.print(table[i][j] + " ");
- }
- System.out.print("\n");
- }
- sc.close();
- } catch (IOException iox) {
- System.out.println("Error while reading datafile.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement