小弟正在做一个图片管理系统,已经实现了能添加树型目录的功能,新建的目录都是放到指定的E:\pictures 没有子目录的功能 因为太麻烦..现在的问题是如何把电脑上的图片保存到E:\pictures里面的目录中,并且实现点击目录中的图片名能把图片显示到Label上.现在把图片直接复制到文件夹中能显示出图片名称,添加图片能在Label上显示,怎么把它们结合起来.
希望高人指点下,有源代码最好,谢谢.

解决方案 »

  1.   

    按照你的需求,实际上是一个文件复制操作,对于文件复制,给你段参考吧:
    public void copyFile(String src,String dest) throws IOException {
            FileInputStream in=new FileInputStream(src);
            File file=new File(dest);
            if(!file.exists())
                file.createNewFile();
            FileOutputStream out=new FileOutputStream(file);
            int c;
            byte buffer[]=new byte[1024];
            while((c=in.read(buffer))!=-1) {
                for(int i=0;i<c;i++)
                    out.write(buffer);        
            }
            in.close();
            out.close();
        }