2014-12-10 1 views
0

이 좋아 그래서, 나는 다음과 같은 오류 메시지가Java, 컴파일하려고하면 다음 오류 메시지가 표시됩니다. 이것이 의미하는 바는 무엇입니까? 나는 자바에서이 컴파일 할 때

오류 얻을 : 클래스의 이름을 'TokenTest'만 허용됩니다 주석 처리를 명시 적으로 무엇을 1 오류

를 요청하는 경우 이 말은 어떻게 고칠 수 있습니까? 나는 수많은 것들을 시도했지만 그것이 의미하는 것을 이해할 수 없습니다. 당신의 도움을 주셔서 감사합니다! 토큰 테스트가 아니기 때문에 이름을 변경해야한다는 의미입니까?

import java.io.*; 

    import java.util.*; 

    class TokenTest { 

    public static void main (String[] args) { 
     TokenTest tt = new TokenTest(); 
     tt.dbTest(); 
    } 
    void dbTest() { 

     DataInputStream dis = null; 
     String dbRecord = null; 

     try { 

      File f = new File("sales.info"); 
      FileInputStream fis = new FileInputStream(f); 
      BufferedInputStream bis = new BufferedInputStream(fis); 
      dis = new DataInputStream(bis); 

      // read the first record of the database 
      while ((dbRecord = dis.readLine()) != null) { 

       StringTokenizer st = new StringTokenizer(dbRecord, ","); 
       String fname = st.nextToken(); 
       String lname = st.nextToken(); 
       String city = st.nextToken(); 
       String state = st.nextToken(); 

       System.out.println("First Name: " + fname); 
       System.out.println("Last Name: " + lname); 
       System.out.println("City:  " + city); 
       System.out.println("State:  " + state + "\n"); 
      } 
     } catch (IOException e) { 
      // catch io errors from FileInputStream or readLine() 
      System.out.println("Uh oh, got an IOException error!" + e.getMessage()); 

     } finally { 
      // if the file opened okay, make sure we close it 
      if (dis != null) { 
       try { 
       dis.close(); 
       } catch (IOException ioe) { 
       } 
      }// end if 
     }// end finally 
    } // end dbTest 
    } // end class 

답변

3

:

while ((dbRecord = dis.readLine()) != null) { 

DataInputStream#readLine가되지 않습니다 때문입니다 :

Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested

If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac HelloWorldApp.java not javac HelloWorldApp .

오류를 수정 한 후에는 다음 줄에 사용되지 않는 방법의 사용에 대한 경고를 얻을 것 . 더 이상 사용되지 않는 이유와 대신 사용할 API를 확인하려면 the class Javadoc page을 참조하십시오.

+0

주 : TokenTest.java는 사용되지 않는 API를 사용하거나 대체합니다. 참고 : 자세한 내용은 -Xlint : deprecation을 사용하여 다시 컴파일하십시오. – Michael

+0

그럴 때 다음 메시지가 나타납니다 – Michael

+0

가치있는 텍스트와 Google을 사용하면이 페이지가 첫 번째 결과임을 알 수 있습니다. – digitaljoel

관련 문제