1
나는 Vigenere Cipher를 사용하여 텍스트 파일의 텍스트를 암호화하고 해독하는 간단한 프로그램을 작성하고 있습니다. 개요 코드는자바 스트림 닫힌 오류
import java.io.*;
public class VigenereCipher
{
public static void main(String [] args)
throws IOException
{
char [][] cipherKey = new char[26][26];
String fileName, keyword;
System.out.println("Enter the file Name to Read");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
fileName = br.readLine();
System.out.println("Enter the Keyword");
keyword = br.readLine();
keyword = keyword.toUpperCase();
br.close();
//to read the file line by line and convert
br = new BufferedReader(new FileReader(fileName));
while((line = br.readLine()) != null){
line = line.toUpperCase();
//More code to perform the substitution, removed to reduce the code
}
br.close();
//code for decryption
System.out.println("Enter the filename to decode");
try
{
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
fileName = br1.readLine();
br1.close();
}catch(Exception ex){ System.out.println(ex.getMessage());}
System.out.println(fileName);
br = new BufferedReader(new FileReader(fileName));
while((line = br.readLine()) != null){
line = line.toUpperCase();
//The decryption code is here
}
br.close();
}
}
내가 System.in 스트림이 닫혀 할 수있는 방법은 try의 catch 블록 이해가 안
Stream closed
에서 다음과 같은 메시지가 아래에 붙여? 어떤 실수를 저지르고 있으며 어떻게 수정합니까?
감사합니다. 그러나 동일한 버퍼링 된 판독기를 사용할 수있는 방법이 있습니까? 이것은 호기심에서 벗어난 것입니다. – nikhil