【发布时间】:2017-02-16 01:57:04
【问题描述】:
我希望我的程序以某种方式输出它,我怎样才能做到这一点?到目前为止,我的代码给了我错误的东西。
这是我的.txt 文件:
ABCDEFGHIJKLMNOPQRSTUVWXYZOOOOOOO
这是我的java 文件:
import java.io.*;
public class EncryptDecrypt {
public static void encrypt() throws IOException {
BufferedReader in = new BufferedReader(new FileReader("cryptographyTextFile.txt"));
String line = in.readLine();
char[][] table = new char[6][5];
// fill array
for(int i = 0; i < 6; i++) {
for(int j = 0; j < 5; j++) {
while(table[i][j] < 6) {
table[i][j] = line.charAt(j);
}
}
}
// print array
for(int i = 0; i < 6; i++) {
for(int j = 0; j < 5; j++) {
System.out.println(table[i][j] + " ");
}
System.out.println();
}
}
public static void main(String[] args) throws IOException {
encrypt();
}
}
我将如何像这样打印这个.txt 文件:
ABCDE
GHIJK
MNOPQ
STUVW
XYZOO
OOOOO
【问题讨论】:
标签: java algorithm for-loop encryption