⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fso.java

📁 对学习 VC有所帮助的几个例子
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   Fso.java

package com.jspsmart.file;

import java.io.*;

// Referenced classes of package com.jspsmart.file:
//            FsoFilenameFilter

public class Fso
{

    Fso()
    {
    }

    public static String getFilename(String s)
    {
        return (new File(s)).getName();
    }

    public static boolean fileExists(String s)
    {
        return (new File(s)).isFile();
    }

    public static void deleteFile(String s)
        throws IOException
    {
        File file = getAbsoluteParent(s);
        String s1 = getFilename(s);
        if(file.isDirectory())
        {
            String as[] = file.list(new FsoFilenameFilter(s1));
            if(as.length == 0)
                throw new FileNotFoundException();
            for(int i = 0; i < as.length; i++)
            {
                File file1 = new File(file, as[i]);
                if(!file1.delete())
                    throw new IOException();
            }

        } else
        {
            throw new FileNotFoundException();
        }
    }

    public static boolean folderExists(String s)
    {
        File file = new File(s);
        return file.exists() && file.isDirectory();
    }

    public static void deleteFolder(String s)
        throws IOException
    {
        File file = getAbsoluteParent(s);
        String s1 = getFilename(s);
        if(file.isDirectory())
        {
            String as[] = file.list(new FsoFilenameFilter(s1));
            if(as.length == 0)
                throw new FileNotFoundException();
            for(int i = 0; i < as.length; i++)
            {
                File file1 = new File(file, as[i]);
                if(!file1.isDirectory() || !deleteFolder(file1))
                    throw new IOException();
            }

        } else
        {
            throw new FileNotFoundException();
        }
    }

    private static boolean deleteFolder(File file)
    {
        String as[] = file.list();
        for(int i = 0; i < as.length; i++)
        {
            File file1 = new File(file, as[i]);
            if(file1.isDirectory())
            {
                if(!deleteFolder(file1))
                    return false;
            } else
            if(!file1.delete())
                return false;
        }

        return file.delete();
    }

    public static void moveFile(String s, String s1)
        throws IOException
    {
        moveObject(s, s1);
    }

    public static void moveFolder(String s, String s1)
        throws IOException
    {
        moveObject(s, s1);
    }

    private static void moveObject(String s, String s1)
        throws IOException
    {
        if(!isPathExact(s) || s1.charAt(s1.length() - 1) == File.separatorChar)
        {
            if(!folderExists(s1))
                throw new IOException();
            File file = new File(s1);
            if(!isPathExact(s))
            {
                File file2 = getAbsoluteParent(s);
                String s2 = getFilename(s);
                if(file2.isDirectory())
                {
                    String as[] = file2.list(new FsoFilenameFilter(s2));
                    if(as.length == 0)
                        throw new FileNotFoundException();
                    for(int i = 0; i < as.length; i++)
                    {
                        File file6 = new File(file2, as[i]);
                        File file7 = new File(file, as[i]);
                        if(file7.exists() || !file6.renameTo(file7))
                            throw new IOException();
                    }

                } else
                {
                    throw new FileNotFoundException();
                }
            } else
            {
                File file3 = new File(s);
                File file5 = new File(file, getFilename(s));
                if(file5.exists() || !file3.renameTo(file5))
                    throw new IOException();
            }
        } else
        {
            File file1 = new File(s);
            File file4 = new File(s1);
            if(file4.exists() || !file1.renameTo(file4))
                throw new IOException();
        }
    }

    public static void copyFile(String s, String s1)
        throws IOException
    {
        if(!isPathExact(s) || s1.charAt(s1.length() - 1) == File.separatorChar)
        {
            if(!folderExists(s1))
                throw new IOException();
            File file = new File(s1);
            if(!isPathExact(s))
            {
                File file2 = getAbsoluteParent(s);
                String s2 = getFilename(s);
                if(file2.isDirectory())
                {
                    String as[] = file2.list(new FsoFilenameFilter(s2));
                    if(as.length == 0)
                        throw new FileNotFoundException();
                    for(int i = 0; i < as.length; i++)
                    {
                        File file6 = new File(file2, as[i]);
                        File file7 = new File(file, as[i]);
                        if(!file7.isDirectory())
                            copyFile(file6, file7);
                        else
                            throw new IOException();
                    }

                } else
                {
                    throw new FileNotFoundException();
                }
            } else
            {
                File file3 = new File(s);
                File file5 = new File(file, getFilename(s));
                if(!file5.isDirectory())
                    copyFile(file3, file5);
                else
                    throw new IOException();
            }
        } else
        {
            File file1 = new File(s);
            File file4 = new File(s1);
            if(!file4.isDirectory())
                copyFile(file1, file4);
            else
                throw new IOException();
        }
    }

    private static void copyFile(File file, File file1)
        throws IOException
    {
        char c = '\u0400';
        byte abyte0[] = new byte[c];
        FileInputStream fileinputstream = new FileInputStream(file);
        BufferedInputStream bufferedinputstream = new BufferedInputStream(fileinputstream);
        FileOutputStream fileoutputstream = new FileOutputStream(file1);
        BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(fileoutputstream);
        int i;
        while((i = fileinputstream.read(abyte0)) != -1) 
            fileoutputstream.write(abyte0, 0, i);
        bufferedoutputstream.close();
        bufferedinputstream.close();
    }

    public static void copyFolder(String s, String s1)
        throws IOException
    {
        if(!isPathExact(s) || s1.charAt(s1.length() - 1) == File.separatorChar)
        {
            if(!folderExists(s1))
                throw new IOException();
            File file = new File(s1);
            if(!isPathExact(s))
            {
                File file2 = getAbsoluteParent(s);
                String s2 = getFilename(s);
                if(file2.isDirectory())
                {
                    String as[] = file2.list(new FsoFilenameFilter(s2));
                    if(as.length == 0)
                        throw new FileNotFoundException();
                    for(int i = 0; i < as.length; i++)
                    {
                        File file6 = new File(file2, as[i]);
                        File file7 = new File(file, as[i]);
                        if(!file7.exists() || file7.isDirectory())
                            copyFolder(file6, file7);
                        else
                            throw new IOException();
                    }

                } else
                {
                    throw new FileNotFoundException();
                }
            } else
            {
                File file3 = new File(s);
                File file5 = new File(file, getFilename(s));
                if(!file5.exists() || file5.isDirectory())
                    copyFolder(file3, file5);
                else
                    throw new IOException();
            }
        } else
        {
            File file1 = new File(s);
            File file4 = new File(s1);
            if(!file4.exists() || file4.isDirectory())
                copyFolder(file1, file4);
            else
                throw new IOException();
        }
    }

    private static void copyFolder(File file, File file1)
        throws IOException
    {
        if(!file1.exists() && !file1.mkdirs())
            throw new IOException();
        if(!file1.isDirectory())
            throw new IOException();
        String as[] = file.list();
        for(int i = 0; i < as.length; i++)
        {
            File file2 = new File(file, as[i]);
            File file3 = new File(file1, as[i]);
            if(file2.isDirectory())
                copyFolder(file2, file3);
            else
                copyFile(file2, file3);
        }

    }

    private static File getAbsoluteParent(String s)
    {
        File file = new File(s);
        File file1 = new File(file.getAbsolutePath());
        File file2 = new File(file1.getParent());
        return file2;
    }

    private static boolean isPathExact(String s)
    {
        return s.indexOf(42) == -1 && s.indexOf(63) == -1;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -