/* 6 / 1 Enkodierung.java */ import java.io.*; import java.util.StringTokenizer; class Enkodierung { public static void main(String[] args) { int n = Integer.parseInt(args[0]); // Argument 1: blocksize String key_file = args[1]; // Argument 2: file with key String encode_file = args[2]; // Argument 3: file to encode int [] s = new int [n]; // contains the key to encode StringTokenizer st = null; // is for parsing the key int read_characters; // counts the number of characters read in char cbuf[] = new char[n]; // contains n characters read in char cbuf_output[] = new char[n]; // contains the encoded block of characters for output FileReader fr = null; BufferedReader in = null; try { // open key_file fr = new FileReader(key_file); in = new BufferedReader(fr); } catch(FileNotFoundException fnfe) { System.out.println("File not found!"); } try { // read key for encoding st = new StringTokenizer(in.readLine()); } catch(IOException ioe) { System.out.println("IOException"); } for (int t=0; t while while ((read_characters = in.read(cbuf, 0, n)) != -1) { // if read_characters < blocksize ==> fill with spaces if (read_characters != n) { // anzahl spaces = blocksize - read_characters, d.h. es ist im vorhinein // klar, wieviele spaces eingefuegt werden muessen ==> for for (int t=n-1; t>=read_characters; t--) { cbuf[t] = ' '; } } // encode // muss n-mal ausgefuehrt werden ==> for for (int t=0; t for for (int t=0; t