开发者

Cannot Find Symbol compiler message

Hello all I'm a java newbie and I'm getting a compiler error message:

src\LU62XnsCvr.java:33: cannot find symbol
symbol  : constructor File(java.lang.StringBuffer)
location: class java.io.File
   static File Rqst_File = new File(RqstFile_DSN) ;
                           ^

In my java program I have coded:

   static StringBuffer RqstFile_DSN = new StringBuffer() ;
   static StringBuffer RespFile_DSN = new StringBuffer() ;

   static File Rqst_File = new File(RqstFile_DSN) ;

Any ideas as to why the compiler can't find the RqstFile_DSN "symbol" ? I'm assuming that the "symbol" is the variable I've defined Rqs开发者_运维问答tFile_DSN

Thanks


The error message is slightly misleading. The problem is that new File cannot take a StringBuilder object as a parameter. This ought to work:

static File Rqst_File = new File(RqstFile_DSN.toString()) ;


The error message is,

cannot find symbol : constructor File(java.lang.StringBuffer)

There is no File constructor that takes a StringBuffer, you need to pass it a String instead.

Try something like,

static final String rqstFile_DSN = "theFileName";
static final File rqstFile = new File(rqstFile_DSN) ;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜