| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 604 人关注过本帖
标题:我的程序好像有问题,帮我看看????
取消只看楼主 加入收藏
Javapet
Rank: 1
等 级:禁止访问
帖 子:80
专家分:0
注 册:2008-1-5
结帖率:50%
收藏
 问题点数:0 回复次数:0 
我的程序好像有问题,帮我看看????
这个程序在编译和运行都没有问题,我的“nihao.txt”这个文件的路径是在:e:\nihao.txt
但当我在文本框输入:http://127.0.0.1/nihao.txt 时,
就出现下面错误信息:
         Connection reset
        at (Unknown Source)
        at (Unknown Source)
        at (Unknown Source)
        at (Unknown Source)
        at (Unknown Source)
        at (Unknown Source)
        at (Unknown Source)
        at (Unknown So
urce)
        at DownLoad$1.actionPerformed(DownLoad.java:54)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
        at java.(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
import *;
import *;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class DownLoad extends JFrame
{
      final JTextField JF;
      JScrollPane JS;
      JLabel JL1;
      JTextArea JA;
      JButton JB;
      JPanel JP1;
      JPanel JP2;
      
      public DownLoad(String str)
      {
              super(str);
              //建立内容面板
              JP1=new JPanel();
              JP2=new JPanel();
              
              //建立组件
            JF=new JTextField(30);
              JL1=new JLabel("URL:");
                 JA=new JTextArea(30,20);
                 JS=new JScrollPane(JA);
              JB=new JButton("下载");
              
              //布置JP1,JP2面板
              JP1.add(JL1);
              JP1.add(JF);
              JP2.add(JB);
              
              //添加组件
              Container c=this.getContentPane();
              c.setLayout(new BorderLayout());
              c.add(JS,BorderLayout.CENTER);
              c.add(JP1,BorderLayout.NORTH);
              c.add(JP2,BorderLayout.SOUTH);
              
              //添加监听器
              JB.addActionListener(new ActionListener()
                                                       {
                                                               public void actionPerformed(ActionEvent e)
                                                               {
                                                                     try
                                                                     {
                                                                               String str=JF.getText();
                                                                               System.out.println(str);
                                                                               URL address=new URL(str);
                                                                               URLConnection conn=address.openConnection();
                                                                               InputStream in=conn.getInputStream();
                                                                               InputStreamReader ISR=new InputStreamReader(in);
                                                                               BufferedReader BR=new BufferedReader(ISR);
                                                                               FileOutputStream FS=new FileOutputStream("1.txt");
                                                                               PrintWriter FO=new PrintWriter(FS,true);
                                                                               FO.println(BR.readLine());
                                                                               BR.close();
                                                                               FO.close();
                                                                     }
                                                                     catch(Exception ee)
                                                                     {
                                                                             ee.printStackTrace();
                                                                     }
                                                               }
                                                       });
              
      }
        public static void main(String[] args)
        {
                DownLoad DL=new DownLoad("下载窗口");
                DL.setSize(500,450);
                DL.setLocation(200,150);
                DL.setVisible(true);
                DL.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
}
2008-03-27 20:42
快速回复:我的程序好像有问题,帮我看看????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034282 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved