由于某种原因,我的代码无法识别打印。
它给了我错误:找不到符号-:方法打印(java.lang.String)
它适用于我制作的另一个代码,但它似乎讨厌这个......
21 System.out.print("What is the input file name? ");
22 String input = console.next();
23 FileInputStream fstream = new FileInputStream("/Users/steph/Desktop/Programming/!6 Problem Set TUES/PartB/6/" + input); //becomes input
24 BufferedReader in = new BufferedReader(new InputStreamReader(fstream));
25 System.out.print("What is the output file name? ");
26 String output = new Scanner(System.in).next();
27
28 char str = input.charAt(0);
29 while (str == 0) {
30 System.out.println (str);
31 }
32 in.close();
35
36 if (i == 1) {
37 String result = caesarEncipher(input, output, in, shift);
38 System.out.println("DONE!");
39 }
40
41 if (i == 2) {
42 String result = caesarDecipher(input, output, in, shift);
43 System.out.println("DONE!");
44 }
45
46 str = input.charAt(0);
47 while (str == 0) {//DON'T WANT THAT B.C LIKELY STICK str AT 0...
48 System.out.println (str);
49 }
50 in.close();
51 }
59 public static String caesarEncipher (String input, String output, BufferedReader in, int shift)
60 throws FileNotFoundException, IOException {
61
62 int [] abc = new int [25];
83 output.print(abc[i] + "\n");
84
85 while (shift < 0) { //move forward (a->b, b->c, etc.); stop when all shifted
86 for (int j = 0; j < shift; j++) {
87 int w = abc[0];
88 i = 0;
89 }
90 for (i = 0; i < (len - 1); i++)
91 abc[i] = abc[i+1];
92 }
93
94 while (shift > 0) { //move backwards (a->z, b->a, etc.); stop when all shifted
95 for (int j = 0; j < shift; j++) {
96 int w = abc[len-1];
97 i = 0;
98 for (i = len-1; i > shift - 1; i--)
99 abc[i] = abc[i-1];
100 abc[i] = w;
101 }
102 }
103
107 for (int x = 0; x < len; x++)
108 output.print(abc[x] + " ");
109 }
110
111 public static String caesarDecipher (String fileName, String output, BufferedReader in, int shift)
112 throws FileNotFoundException, IOException {
113
114 int [] abc = new int [25];
115
135 output.print(abc[i] + "\n");
136 while (shift < 0) { //move forward (a->b, b->c, etc.); stop when all shifted
137 for (int j = 0; j < shift; j++) {
138 int w = abc[0];
139 i = 0;
140 }
141 for (i = 0; i < (len - 1); i++)
142 abc[i] = abc[i+1];
143 }
144
145 while (shift > 0) { //move backwards (a->z, b->a, etc.); stop when all shifted
146 for (int j = 0; j < shift; j++) {
147 int w = abc[len-1];
148 i = 0;
149 for (i = len-1; i > shift - 1; i--)
150 abc[i] = abc[i-1];
151 abc[i] = w;
152 }
153 }
157
158 for (int x = 0; x < len; x++)
159 output.print(abc[x] + " ");
在第 83、108、135 和 159 行,它们都说了同样的话:
找不到符号 symbol : method print(java.lang.String)