2012-08-07 4 views
-1

내 코드가 어떤 이유로 든 인쇄를 인식하지 못합니다.기호를 인식 할 수 없습니다. output()

그것은 나에게 오류 제공 : 기호를 찾을 수 없습니다 - : 방법 인쇄 (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, 그들 모두가 똑같은 말 :
심볼 기호를 찾을 수 없습니다 : 방법 인쇄 (java.lang.String의) 그래서

+2

문제가 어디에 있는지 분명하지 않습니다. 입니다. * 짧은 *하지만 문제를 보여주는 완전한 프로그램을 보여주십시오. –

+0

오류 메시지에 줄 번호가 포함되어 있습니까? 처음 몇 가지 오류의 전문을 제공 할 수 있습니까? –

+0

변경 사항 중 일부를 롤백 할 수 있습니까? 'in '의 문제는 모든 필드가 무엇인지를 볼 수있을 때 분명했습니다. –

답변

1

, 당신이 있었다 이유를문제가 발생했습니다.은 한 메서드에서 로컬 변수로 선언했지만 다른 메서드에서 액세스하려고했습니다 (편집에서 많은 코드가 제거되기 전에이를 볼 수있었습니다). 어디에서나 사용하고 싶다면 필드로 만드십시오.

output의 문제는 12332 행을 보면 output에 PrintStream이 아닌 String이 있습니다. (아마도 여러분의 PrintStream은 여러 장소에서 접근하기를 원하기 때문에 필드가되어야 할 것입니다. 다 끝난 후에 실수로 다른 변수에 같은 이름을 부여하지 않도록하십시오.)

+0

문제가 해결되었습니다. 감사!! – user1582825

관련 문제