这个好像有点难度,提供思路:
你可以调用WindowsAPI实现列出目录,这一步实现后,循环列出每个目录下的每个文件,判断文件扩展名,如果是.txt那么打开文件读进数据库。

解决方案 »

  1.   

    可以参考weblogic的管理界面的代码
      

  2.   

    可以参考weblogic的管理界面的代码
      

  3.   

    用低归函数:
    给你一个参考:
    public String[] getFileList(String fpath)
        {
           String[] f1;
           File f=new File(fpath);
           f1=f.list();
           return f1;
         }
       public File[] getFileObjList(String fpath)
        {
           File[] f1;
           File f=new File(fpath);
           f1=f.listFiles();
           return f1;
         } 
    public void create(String fpath)
        {
           
           String name=null;
       
          String[] flist=getFileList(fpath);
            File[] fobj=getFileObjList(fpath);       
            
          for(int j=0;j<flist.length;j++)
           {        
             name=flist[j];
             
            System.out.println(name);      if(fobj[j].isDirectory())
         {
           String fpathnext=fpath+"/";
           create(fpathnext);
          }     }
      }
      

  4.   

    给你我程序中的一段代码,已实现你要求的功能package com.test;
    /**
     * Title: 软件工程</p>
     * Description: 图片查看器</p>
     * Copyright: Copyright (c) 2003</p>
     * Company: 北京软件技术有限公司</p>
     * @author BEIJING_GAOCL
     * @version 1.0
     */import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;public class ImageViewer extends JFrame
       implements ActionListener
    {  public ImageViewer()
       {  setTitle("图片查看器");
          setSize(300, 400);      JMenuBar mbar = new JMenuBar();
          JMenu m = new JMenu("文件");
          openItem = new JMenuItem("打开");
          openItem.addActionListener(this);
          m.add(openItem);
          exitItem = new JMenuItem("退出");
          exitItem.addActionListener(this);
          m.add(exitItem);
          mbar.add(m);
          setJMenuBar(mbar);      label = new JLabel();
          Container contentPane = getContentPane();
          contentPane.add(label, "Center");
       }   public void actionPerformed(ActionEvent evt)
       {  Object source = evt.getSource();
          if (source == openItem)
          {  JFileChooser chooser = new JFileChooser();
             chooser.setCurrentDirectory(new File("."));         chooser.setFileFilter(new
                javax.swing.filechooser.FileFilter()
                {  public boolean accept(File f)
                   {  return f.getName().toLowerCase()
                         .endsWith(".gif")
                         || f.isDirectory();
                   }
                   public String getDescription(){
                     return "GIF 图片";
                   }
                });         int r = chooser.showOpenDialog(this);
             if(r == JFileChooser.APPROVE_OPTION)
             {  String name
                   = chooser.getSelectedFile().getName();
                label.setIcon(new ImageIcon(name));
             }
          }
          else if (source == exitItem) System.exit(0);
       }   public static void main(String[] args){
         JFrame frame = new ImageViewer();
          frame.show();
       }   private JLabel label;
       private JMenuItem openItem;
       private JMenuItem exitItem;
    }