【发布时间】:2016-01-04 23:24:38
【问题描述】:
任何想法为什么我不断收到运行时错误?我很新,请放轻松。我正在尝试接受用户输入以生成非常简单的文件加密。我收到一个错误:
静态错误:此类没有接受 String[] 的静态 void main 方法。
我有一个接受字符串[]的主要方法!我迷路了。有什么建议吗?
import java.io.*;
import java.util.Scanner;
public class Encryption
{
public static void main(String[] args, String existing, String encrypted) throws IOException
{
boolean eof = false;
int key = 10;
Scanner scan = new Scanner(System.in);
key = scan.nextInt();
/* Your encryption program should work like a filter, reading the contents of one file...
*/
FileInputStream inStream = new FileInputStream(existing);
DataInputStream inFile = new DataInputStream(inStream);
FileOutputStream outStream = new FileOutputStream(encrypted);
DataOutputStream outFile = new DataOutputStream(outStream);
while (!eof)
{
try
{
byte input = inFile.readByte();
/* modifying the data into a code...
*/
input += key;
/* and then writing the coded contents out to a second file.
* The second file will be a version of the first file, but written in a secret code.
*/
outFile.writeByte(input);
}
catch (EOFException e)
{
eof = true;
}
}
}
}
【问题讨论】:
标签: java class input java.util.scanner main