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

📄 lastconnections.java

📁 一个JAVA做的FTP软件,带源码的,可以很好的进行二次开发,,并带有详细说明文件的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    j++;                }                newString[j] = SENTINEL;                //System.out.println("$$$$$$$$$$$$$");                //store lastCons data in temp again                j = 0;                //while (!(temp[j].equals(SENTINEL))) {                while(!(lastCons[i + 1][j].equals(SENTINEL)))                {                    //newString[j] = temp[j];                    temp[j] = lastCons[i + 1][j];                    //temp[j] = lastCons[i + 1][j];                    //lastCons[i+1][j] = newString[j];                    //j++;                    //System.out.println(lastCons[i+1][j]);                    //System.out.println(temp[j]);                    //if (temp[j].equals(SENTINEL))                    //if (lastCons[i][j].equals(SENTINEL))                    //break;                    //temp[j] = lastCons[i+1][j];                    j++;                }                //while                temp[j] = SENTINEL;                //System.out.println("+-+-+-+-+-+-");                //then, make adjustments to lastCons                j = 0;                //while (!(lastCons[i+1][j].equals(SENTINEL))) {                while(!(newString[j].equals(SENTINEL)))                {                    lastCons[i + 1][j] = newString[j];                    //System.out.println(lastCons[i+1][j]);                    j++;                }                lastCons[i + 1][j] = SENTINEL;                //j=0;                /*                while (!(lastCons[i][j].equals(SENTINEL))) {                        temp[j] = lastCons[i+1][j];                        j++;                }                */                //lastCons[i+1][j] = SENTINEL;            }            //if        }        //for        for(int i = 0; i < capacity; i++)        {            j = 0;            while(!lastCons[i][j].equals(SENTINEL))            {                //System.out.println(lastCons[i][j]);                if(lastCons[i][j].equals(SENTINEL))                {                    break;                }                j++;            }            //System.out.println(lastCons[i][j]);        }        //***        if(newConnection)        {            writeToFile(lastCons, capacity);        }        return lastCons;    }    //prepend    public static String[][] moveToFront(int position, int capacity)    {        //make these 2D        //String[] lastCons = new String[capacity];        //String[] newLastCons = new String[capacity];        String[][] lastCons = new String[capacity][JFtp.CONNECTION_DATA_LENGTH];        String[][] newLastCons = new String[capacity][JFtp.CONNECTION_DATA_LENGTH];        //System.out.print("--------:");        //System.out.println(capacity);        lastCons = readFromFile(capacity);        //String temp = new String("");        String[] temp = new String[JFtp.CONNECTION_DATA_LENGTH];        //String[] lastCons = new String[capacity];        int j = 0;        temp[j] = lastCons[position][j];        while(!(lastCons[position][j].equals(SENTINEL)))        {            j++;            temp[j] = lastCons[position][j];        }        j = 0;        //System.out.println("START");        while(!(lastCons[position][j].equals(SENTINEL)))        {            //System.out.println(lastCons[position][j]);            j++;        }        //System.out.println("END");        //possible bugfix code?        /*        for (int i=0; i<JFtp.CONNECTION_DATA_LENGTH; i++) {                temp[i] = lastCons[position][i];        }        */        newLastCons = prepend(temp, position + 1, false);        for(int i = 0; i <= position; i++)        {            j = 0;            //while (!(lastCons[position][i].equals(SENTINEL))) {            //while (!(lastCons[i][j].equals(SENTINEL))) {             while(!(newLastCons[i][j].equals(SENTINEL)))            {                //j++;                      //temp[i] = lastCons[position][i];                //System.out.println(i);                //System.out.println(j);                //System.out.println(newLastCons[i][j]);                lastCons[i][j] = newLastCons[i][j];                j++;            }            lastCons[i][j] = SENTINEL;        }        //for        writeToFile(lastCons, capacity);        return lastCons;    }    //moveToFront    public static int findString(String[] findVal, int capacity)    {        //BUGFIX: 2D        //String[] lastCons = new String[capacity];        String[][] lastCons = new String[capacity][JFtp.CONNECTION_DATA_LENGTH];        lastCons = readFromFile(capacity);        for(int i = 0; i < capacity; i++)        {            int j = 0;            while((j < JFtp.CAPACITY) && findVal[j].equals(lastCons[i][j]) &&                      !(lastCons[i][j].equals(SENTINEL)) &&                      !(findVal[j].equals(SENTINEL)))            {                //System.out.println("start ");                //System.out.print(lastCons[i][j]);                //System.out.print(findVal[j]);                //System.out.println("end");                j++;                //if (findVal.equals(lastCons[i]))                //return i;            }            if(findVal[j].equals(lastCons[i][j]))            {                //System.out.println("test");                //System.out.println(lastCons[i][j]);                //System.out.println(findVal[j]);                return i;            }            else            {                //System.out.println("test2");                //System.out.println(lastCons[i][j]);                //System.out.println(findVal[j]);                //System.out.println("NO");            }        }        //if not found, return -1        return -1;    }    //findString    /*    //unnecessary?    public static String[] swap(String a[], int pos1, int pos2) {            String temp = new String("");            temp = a[pos2];            a[pos2] = a[pos1];            a[pos1] = temp;            return a;    } //swap    */    private static void init(int capacity)    {        //File f = new File(Settings.last_cons);        try        {            FileOutputStream fos;            PrintStream out;            fos = new FileOutputStream(Settings.last_cons);            out = new PrintStream(fos);            for(int i = 0; i < capacity; i++)            {                out.println("null");                out.println(SENTINEL);            }            fos.close();        }        catch(Exception e)        {            e.printStackTrace();        }        //return f;    }    //init    private static void changeFile(String[] oldValues)    {        StringTokenizer tokens;        String[][] newData = new String[JFtp.CAPACITY][JFtp.CONNECTION_DATA_LENGTH];        //this assumes that capacity will not change        //should this be set to 9 instead of JFtp.CAPACITY?        for(int i = 0; i < JFtp.CAPACITY; i++)        {            //System.out.println(oldValues[i]);            tokens = new StringTokenizer(oldValues[i], " ");            int j = 0;            while((tokens.hasMoreTokens()))            {                newData[i][j] = tokens.nextToken();                //System.out.println(newData[i][j]);                j++;            }            newData[i][j] = SENTINEL;            //System.out.print("---->");            //System.out.println(newData[i][0]);            //System.out.println(j);            //for backwards compatibility with versions that            //don't have SFTP port remembered: enter port 22            //(which is default) there            if(newData[i][0].equals("SFTP") && (j == 5))            {                String temp = new String("");                String temp2 = new String("");                temp = newData[i][4];                newData[i][4] = "22";                temp2 = newData[i][5];                newData[i][5] = temp;                //temp2 = newData[i][5];                //newData[i][6] = temp2;                //newData[i][7] = SENTINEL;                newData[i][6] = SENTINEL;                /*                for (int j=5; j++; j<7) {                        temp = newData[i][j];                        newData[i][j] = newData[i][j-1];                } */            }            //if        }        //for        writeToFile(newData, JFtp.CAPACITY);    }    //changeFile}//LastConnections

⌨️ 快捷键说明

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