import java.util.Properties;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;public class inout {
  public inout() {
  }  public static void main(String[] args) throws FileNotFoundException,
      IOException {
    inout inout = new inout();
    Properties setupfile = new Properties();
    FileInputStream fis = new FileInputStream("2.txt");
    setupfile.load(fis);  }
}我在硬盘(d)上建立了一个D:\2.txt   文件
程序运行之后就出错。
错误如下:
Exception in thread "main" java.io.FileNotFoundException: 2.txt (指定されたファイルが見つかりません。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at get.picture.from.panel.inout.main(inout.java:16)
Debug之后的错误:
Hit uncaught exception java.io.FileNotFoundException

解决方案 »

  1.   

    没找到文件FileInputStream   fis   =   new   FileInputStream("2.txt"); 
    改成
    FileInputStream   fis   =   new   FileInputStream("d:\\2.txt"); 
      

  2.   

    默认情况下2.txt是相对路径,一般要和你的class文件在同一个目录
      

  3.   

    import   java.util.Properties; 
    import   java.io.FileInputStream; 
    import   java.io.FileNotFoundException; 
    import   java.io.IOException; public   class   inout   { 
        public   inout()   { 
        }     public   static   void   main(String[]   args)   throws   FileNotFoundException, 
                IOException   { 
            inout   inout   =   new   inout(); 
            Properties   setupfile   =   new   Properties(); 
            FileInputStream   fis   =   new   FileInputStream("2.txt"); 
            //错误信息是:没有发现2.txt文件,原因是路径问题,你的2.txt要么放在class目录下,要么就放到src目录下,这样就可以编译到class目录下
            setupfile.load(fis);     } 

      

  4.   

    文件没有找到 的 
    d://2.txt
      

  5.   

    又一个挺简单的问题  呵呵  (初学者,大家见谅)建立会话并且认证
          Session session = Session.getDefaultInstance(props,
              new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication(user, password);
            }
          }
          )
    这段代码是不是就是 用账号和密码 连接到邮箱  或者是  登陆到邮箱上
    怎么检查是不是 已经建立好连接了  我想用System.out.print() 来写