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

📄 io.java

📁 该系统是B/S结构的
💻 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:   Io.java

package syi.util;

import java.awt.*;
import java.io.*;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Io
{

    public static void copyDirectory(File file, File file1)
    {
        try
        {
            if(!file1.exists())
                file1.mkdirs();
            String as[] = file.list();
            for(int i = 0; i < as.length; i++)
            {
                File file2 = new File(file, as[i]);
                if(file2.isFile())
                    copyFile((new File(file, as[i])).getCanonicalPath(), file1.getCanonicalPath(), true);
                else
                    copyDirectory(new File(file, as[i]), new File(file1, as[i]));
            }

        }
        catch(IOException ioexception)
        {
            ioexception.printStackTrace();
        }
    }

    public static boolean copyFile(File file, File file1)
    {
        try
        {
            byte abyte0[] = new byte[(int)file.length()];
            FileInputStream fileinputstream = new FileInputStream(file);
            rFull(fileinputstream, abyte0, 0, abyte0.length);
            fileinputstream.close();
            FileOutputStream fileoutputstream = new FileOutputStream(file1);
            fileoutputstream.write(abyte0, 0, abyte0.length);
            fileoutputstream.flush();
            fileoutputstream.close();
            return true;
        }
        catch(IOException ioexception)
        {
            ioexception.printStackTrace();
        }
        return false;
    }

    public static boolean copyFile(String s, String s1, boolean flag)
    {
        try
        {
            File file = new File(s);
            if(!file.exists())
                throw new FileNotFoundException();
            File file1;
            if(flag)
            {
                File file2 = toDir(s1);
                if(!file2.exists())
                    file2.mkdirs();
                file1 = new File(file2, getFileName(s));
            } else
            {
                File file3 = toDir(getDirectory(s1));
                if(!file3.exists())
                    file3.mkdirs();
                file1 = new File(s1);
            }
            byte abyte0[] = new byte[4000];
            FileInputStream fileinputstream = new FileInputStream(file);
            FileOutputStream fileoutputstream = new FileOutputStream(file1);
            int i;
            while((i = fileinputstream.read(abyte0)) != -1) 
                fileoutputstream.write(abyte0, 0, i);
            fileoutputstream.flush();
            fileoutputstream.close();
            fileinputstream.close();
            return true;
        }
        catch(IOException ioexception)
        {
            System.out.println("copy" + ioexception);
        }
        catch(RuntimeException runtimeexception)
        {
            System.out.println("copy" + runtimeexception);
        }
        return false;
    }

    public static String getCurrent()
    {
        return System.getProperty("user.dir", "/");
    }

    public static final String getDateString(String s, String s1, String s2)
    {
        String s3 = '.' + s1;
        String s4 = null;
        File file = new File(s2);
        if(!file.exists())
            file.mkdirs();
        try
        {
            GregorianCalendar gregoriancalendar = new GregorianCalendar();
            String s5 = s + gregoriancalendar.get(2) + '-' + gregoriancalendar.get(5) + '_';
            int i;
            for(i = 0; i < 256; i++)
            {
                File file1 = new File(s2, s5 + i + s3);
                if(file1.isFile())
                    continue;
                s4 = s2 + "/" + s5 + i + s3;
                break;
            }

            if(i >= 32767)
                s4 = s2 + "/" + s + "over_file255" + s3;
        }
        catch(RuntimeException _ex)
        {
            s4 = s + "." + s1;
        }
        return s4;
    }

    public static File getDirectory(File file)
    {
        try
        {
            return new File(getDirectory(file.getCanonicalPath()));
        }
        catch(IOException _ex)
        {
            return null;
        }
    }

    public static String getDirectory(String s)
    {
        if(s == null || s.length() <= 0)
            return "./";
        if(s.indexOf(92) >= 0)
            s = s.replace('\\', '/');
        int i = s.lastIndexOf(47);
        if(i < 0)
            return "./";
        int j = s.indexOf(46, i);
        if(j < i)
        {
            if(s.charAt(s.length() - 1) != '/')
                s = s + '/';
        } else
        {
            s = s.substring(0, j + 1);
        }
        return s;
    }

    public static String getFileName(String s)
    {
        if(s.lastIndexOf(46) < 0)
            return "";
        int i = s.lastIndexOf(47);
        if(i < 0)
            i = s.lastIndexOf(92);
        if(i < 0)
            return s;
        else
            return s.substring(i + 1);
    }

    public static Image loadImageNow(Component component, String s)
    {
        Image image = null;
        try
        {
            image = component.getToolkit().getImage(s);
            MediaTracker mediatracker = new MediaTracker(component);
            mediatracker.addImage(image, 0);
            mediatracker.waitForID(0, 10000L);
            mediatracker.removeImage(image);
            mediatracker = null;
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
        return image;
    }

    public static String loadString(File file)
        throws IOException
    {
        StringBuffer stringbuffer = new StringBuffer();
        BufferedReader bufferedreader = new BufferedReader(new FileReader(file));
        int i;
        while((i = bufferedreader.read()) != -1) 
            stringbuffer.append((char)i);
        bufferedreader.close();
        return stringbuffer.toString();
    }

    public static File makeFile(String s, String s1)
    {
        File file = toDir(s);
        if(!file.exists())
            file.mkdirs();
        return new File(file, s1);
    }

    public static final void moveFile(File file, File file1)
        throws Throwable
    {
        if(!file.renameTo(file1))
        {
            copyFile(file, file1);
            file.delete();
        }
    }

    public static final int r(InputStream inputstream)
        throws IOException
    {
        int i = inputstream.read();
        if(i == -1)
            throw new EOFException();
        else
            return i;
    }

    public static final int readInt(InputStream inputstream)
        throws IOException
    {
        int i = inputstream.read();
        int j = inputstream.read();
        int k = inputstream.read();
        int l = inputstream.read();
        if((i | j | k | l) < 0)
            throw new EOFException();
        else
            return (i << 24) + (j << 16) + (k << 8) + l;
    }

    public static final short readShort(InputStream inputstream)
        throws IOException
    {
        int i = inputstream.read();
        int j = inputstream.read();
        if((i | j) < 0)
            throw new EOFException();
        else
            return (short)((i << 8) + j);
    }

    public static final int readUShort(InputStream inputstream)
        throws IOException
    {
        int i = inputstream.read();
        int j = inputstream.read();
        if((i | j) < 0)
            throw new EOFException();
        else
            return (i << 8) + j;
    }

    public static final void rFull(InputStream inputstream, byte abyte0[], int i, int j)
        throws EOFException, IOException
    {
        int k;
        for(j += i; i < j; i += k)
        {
            k = inputstream.read(abyte0, i, j - i);
            if(k == -1)
                throw new EOFException();
        }

    }

    public static File toDir(String s)
    {
        String s1 = "./";
        if(s == null || s.length() <= 0)
            return new File(s1);
        if(s.indexOf(92) >= 0)
            s = s.replace('\\', '/');
        if(s.charAt(s.length() - 1) != '/')
            s = s + '/';
        return new File(s);
    }

    public static final void wInt(OutputStream outputstream, int i)
        throws IOException
    {
        outputstream.write(i >>> 24);
        outputstream.write(i >>> 16 & 0xff);
        outputstream.write(i >>> 8 & 0xff);
        outputstream.write(i & 0xff);
    }

    public static final void wShort(OutputStream outputstream, int i)
        throws IOException
    {
        outputstream.write(i >>> 8 & 0xff);
        outputstream.write(i & 0xff);
    }

    public Io()
    {
    }
}

⌨️ 快捷键说明

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