先弄个文件对话框,然后将选择的路径:
new File("../_Bak/file.txt");

解决方案 »

  1.   

    不知道你的意思是不是说弹出“下载文件对话框”,我原先作过一个在jsp中实现文件动态下载的程序
    http://dag.suse.edu.cn/introduce/
    如果是的话,你可以用这个Email跟我联系:[email protected]
    全部原代码免费提供
      

  2.   

    谢谢大家,是我没说清楚。我做一个简单的备份数据库的程序,需要用户选择备份文件的路径,希望有“保存文件”那样的对话框。 谢谢你,BillyW(阿弥陀佛) ,能给一下applet实现的源代码吗?或者是具体一点的思路也好! 
       
     
      

  3.   

    直接以流方式write出来也可以实现
      

  4.   

    希望有“保存文件”那样的对话框。 
    -------------------这不就是弹出下载文件对话框吗写个servlet调用我这个方法
     private void down_FILE(HttpServletRequest req,HttpServletResponse resp,String szPath_file,String szFile_name)
        {
            String  szServer_path="";
            szServer_path=szPath_file;
            BufferedInputStream  bis = null;
            BufferedOutputStream bos = null;
            try
            {
               //和java.io.PrintWriter out 不能共用
                ServletOutputStream outm = null;
                try
                {
                    outm=resp.getOutputStream();
                }
                catch(Exception e)
                {
                     exceptionOutput(resp,e.toString()+" abcd");
                }
                resp.setContentType( "application/octet-stream" ); // MIME type for exe
                resp.setHeader("Content-disposition","attachment; filename="+szFile_name);//显示的随机文件名,可以用这个保存或另起一个名
                // Open file
                File f1;
                szServer_path = szServer_path+"filename.xls" ;
                try
                {
                    f1=new File(szServer_path);
                    FileInputStream fis=new FileInputStream(f1);
                    bis = new BufferedInputStream(fis);
                    bos = new BufferedOutputStream(outm);
                    byte[] buff = new byte[2048];
                    int bytesRead;
                    while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
                    {
                        bos.write(buff, 0, bytesRead);
                    }            }
                catch(Exception e)
                {
                }
            }
            finally
            {
                try
                {
                    if (bis != null) bis.close();
                    if (bos != null) bos.close();
                }
                catch(IOException e)
                {
                }
            }
        }