Java I';我的程序出错了

Java I';我的程序出错了,java,mysql,arrays,intellij-idea,Java,Mysql,Arrays,Intellij Idea,我得到了这个错误: Information:Using javac 1.8.0 to compile java sources Information:java: Errors occurred while compiling module 'HelloWorld' Information:Compilation completed with 2 errors and 0 warnings in 6 sec Information:2 errors Information:0 warnings

我得到了这个错误:

Information:Using javac 1.8.0 to compile java sources
Information:java: Errors occurred while compiling module 'HelloWorld'
Information:Compilation completed with 2 errors and 0 warnings in 6 sec
Information:2 errors
Information:0 warnings
C:\Users\Raj\IdeaProjects\HelloWorld\src\CopyCharacters.java
Error:(18, 29) java: cannot find symbol
  symbol:   variable c
  location: class CopyCharacters
Error:(21, 30) java: cannot find symbol
  symbol:   variable c
  location: class CopyCharacters
我正在做这个练习,现在当我使用intellij idea运行我的程序时,它给了我这个错误

这是我的源代码:

import java.io.*;

public class CopyCharacters {
    public static void main(String[] args) throws IOException{

        FileReader inputstream=null;
        FileWriter outputstream=null;

        try{
            inputstream=new FileReader("D://raj.txt");
            outputstream=new FileWriter("D://raj1.txt");

            int c;
            while((c=inputstream.read())!=-1){
                outputstream.write(c);
            }
        }finally{
            if(inputstream!=c){
                inputstream.close();
            }
            if(outputstream!=c){
                outputstream.close();
            }
        }
    }
}
已编辑

根据@我希望我能想到一个好的答案,它正在工作,但它显示出新的错误:

Exception in thread "main" java.lang.ClassNotFoundException: ArrayDemo
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:259)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)

移动int c;到外试块

import java.io.*;

public class CopyCharacters {
    public static void main(String[] args) throws IOException{

        FileReader inputstream=null;
        FileWriter outputstream=null;
int c=0;

        try{
            inputstream=new FileReader("D://raj.txt");
            outputstream=new FileWriter("D://raj1.txt");

            //int c;
            while((c=inputstream.read())!=-1){
                outputstream.write(c);
            }
        }finally{
            if(inputstream!=c){
                inputstream.close();
            }
            if(outputstream!=c){
                outputstream.close();
            }
        }
    }
}

在这里,在TRY块中声明变量C。无法在外部访问的,请尝试。在这里,你们可以访问Finally块,它给出了一个错误。全局声明int c。

将最终阻止更改为

    }finally{
        if(inputstream!=null){
            inputstream.close();
        }
        if(outputstream!=null){
            outputstream.close();
        }
    }
为什么要将流与int进行比较


这样做之后,您会发现您可以保持
c
的声明原样。

我不明白您为什么要尝试将
int
读取器进行比较

if(inputstream!=c){
它们是不相容的,无法比较,这毫无意义

因为您使用的是Java1.8,所以您可以利用该功能,它将自动关闭您的流,例如

try (FileReader inputstream = new FileReader("D://raj.txt")) {
    try (FileWriter outputstream = new FileWriter("D://raj1.txt")) {
        int c;
        while ((c = inputstream.read()) != -1) {
            outputstream.write(c);
        }
    } finally {
    }
} finally {
}

在try块外声明变量c这与MySQL有什么关系?您在try块内声明了变量c,并试图在finally块中访问。将声明移到try block之外我是根据这一点做的。我看不出编辑与原始问题有什么关系。我现在按照你说的做了,它显示了这个错误:
错误:(18,27)java:不可比较的类型:java.io.FileReader和int
错误:(21,28)java:不可比较的类型:java.io.FileWriter和int
为什么要将
int
FileReader
进行比较?@MadProgrammer我不是将int与FileReader进行比较,我只是回答了原始问题(未找到符号c)。将filreader与int进行比较是OP的另一个问题。我没有回答这个问题。。最后它的工作,但有一个新的错误,请解决我的问题,你几乎在那里。。。请查看我的编辑:)其中使用的是
ArrayDemo
。我看不到你的代码。哦,我想这是IDE的问题。。。我用的是intellij的主意。。第一次,我以前为ArrayDemo创建过一个项目,所以我删除了那个程序并在上面创建了一个新类。。。我想这就是为什么我会得到这个//你更喜欢java的IDE是什么?