{  Hashtable users = new Hashtable();   File dir = new File(m_dir); File dir1 = new File("old" + m_dir);   if(dir1.exists()) { System.out.println("old" + m_dir + " already exists! Deleting..."); if(dir1.isDirectory()) deleteFolder(dir1); else dir1.delete(); }   dir.renameTo(dir1); dir.mkdir();   if(!dir1.exists() || !dir1.isDirectory() || !dir1.canRead() || !dir1.canWrite()) { System.out.println("Permission denied to " + dir1.getAbsolutePath() + ": Please check if you have the right permissions."); return false; }   String reglist[] = dir1.list();   String name; String password; long rights; String color; String lastlogin; Hashtable props; String line;  for(int i = 0; i < reglist.length; ++i) { String file = reglist[i]; FileInputStream fileinputstream = null; try { fileinputstream = new FileInputStream(dir1.getAbsolutePath() + "/" + file); } catch(java.io.FileNotFoundException e) { System.out.println("Error opening " + file + "! Continue with next file..."); continue; } BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(fileinputstream));  name = ""; password = ""; rights = 0; color = ""; lastlogin = ""; props = new Hashtable(); line = "";   name = bufferedreader.readLine(); password = bufferedreader.readLine();   if(name == null || password == null) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   line = bufferedreader.readLine();   if(line == null) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   if(m_format == 1) {  try { rights = Long.parseLong(line); } catch(NumberFormatException e) { rights = 0; }   color = bufferedreader.readLine(); lastlogin = bufferedreader.readLine();   line = bufferedreader.readLine();   if(color == null || lastlogin == null || line == null) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   if(!line.equals("--REGITEMS--")) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   while((line = bufferedreader.readLine()) != null) {  String[] split = line.split("=", 2);   if(split.length != 2) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   props.put("reginfo_" + split[1], split[2]); } }  else {  line = bufferedreader.readLine();   if(line == null || !line.equals("---REGITEMS---")) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   while((line = bufferedreader.readLine()) != null) {  String[] split = line.split("=", 2); if(split.length != 2) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   if(split[1].startsWith("reg_")) {   props.put("reginfo_" + split[1].substring(4), split[2].substring(1, split[2].length() - 1)); }  else if(split[1].equals("rights")) { try { rights = Long.parseLong(split[2]); } catch(NumberFormatException e) { rights = 0; } }  else if(split[1].equals("color")) {  color = split[2].substring(1, split[2].length() - 1); }  else if(split[1].equals("lastlogin")) {  lastlogin = split[2].substring(1, split[2].length() - 1); } else {  if(split[2].startsWith("\"") && split[2].endsWith("\"")) {  props.put(split[1], split[2].substring(1, split[2].length() - 1)); }  else { try { props.put(split[1], new Long(split[2])); } catch(NumberFormatException e) { } } } } }   System.out.println("name = " + name); System.out.println("password = " + name); System.out.println("rights = " + Long.toString(rights)); System.out.println("color = " + name); System.out.println("lastlogin = " + name); System.out.println(); for(Enumeration e = props.keys(); e.hasMoreElements();) { String key = (String)e.nextElement(); Object value = props.get(key); System.out.println(key + " = " + value.toString()); }  System.out.println(); System.out.println();     }  return true; }
{  Hashtable users = new Hashtable();  File dir; File dir1;   dir = new File(m_dir); dir1 = new File(m_dir + "old");   if(!dir.renameTo(dir1)) { System.out.println(dir1.getAbsolutePath() + " already exists! Deleting..."); if(!deleteFolder(dir1) && !dir1.delete()) { System.out.println("Deleting failed!"); return false; } else dir.renameTo(dir1); }   dir.mkdir();   if(!dir1.exists() || !dir1.isDirectory() || !dir1.canRead() || !dir1.canWrite()) { System.out.println("Permission denied to " + dir1.getAbsolutePath() + ": Please check if you have the right permissions."); return false; }   String reglist[] = dir1.list();   String name; String password; long rights; String color; String lastlogin; Hashtable props; String line;  for(int i = 0; i < reglist.length; ++i) { String file = reglist[i]; System.out.println("Processing " + file + "..."); FileInputStream fileinputstream = null; try { fileinputstream = new FileInputStream(dir1.getAbsolutePath() + "/" + file); } catch(java.io.FileNotFoundException e) { System.out.println("Error opening " + file + "! Continue with next file..."); continue; } BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(fileinputstream));  name = ""; password = ""; rights = 0; color = ""; lastlogin = ""; props = new Hashtable(); line = "";   name = readLine(bufferedreader); password = readLine(bufferedreader);   if(name == null || password == null) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   line = readLine(bufferedreader);   if(line == null) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   if(m_format == 1) {  try { rights = Long.parseLong(line); } catch(NumberFormatException e) { rights = 0; }   color = readLine(bufferedreader); lastlogin = readLine(bufferedreader);   line = readLine(bufferedreader);   if(color == null || lastlogin == null || line == null) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   if(!line.equals("--REGITEMS--")) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   while((line = readLine(bufferedreader)) != null) {  String[] split = line.split("=", 2);   if(split.length != 2) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   props.put("reginfo_" + split[0], split[1]); } }  else {  line = readLine(bufferedreader);   if(line == null || !line.equals("---REGITEMS---")) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   while((line = readLine(bufferedreader)) != null) {  String[] split = line.split("=", 2); if(split.length != 2) { System.out.println("Damaged file " + file + " - skipping..."); continue; }   if(split[0].startsWith("reg_") && !split[0].equals("reg_activated")) {   props.put("reginfo_" + split[0].substring(4), split[1].substring(1, split[1].length() - 1)); }  else if(split[0].equals("rights")) { try { rights = Long.parseLong(split[1]); } catch(NumberFormatException e) { rights = 0; } }  else if(split[0].equals("color")) {  color = split[1].substring(1, split[1].length() - 1); }  else if(split[0].equals("lastlogin")) {  lastlogin = split[1].substring(1, split[1].length() - 1); } else {  if(split[1].startsWith("\"") && split[1].endsWith("\"")) {  props.put(split[0], split[1].substring(1, split[1].length() - 1)); }  else { try { props.put(split[0], new Long(split[1])); } catch(NumberFormatException e) { } } } } }   FileOutputStream fileoutputstream = null; try { fileoutputstream = new FileOutputStream(m_dir + "/" + name.toLowerCase() + ".yrf"); } catch(java.io.FileNotFoundException e) { System.out.println("Error opening " + name + ".yrf! Continue with next file..."); continue; }  PrintStream printstream = new PrintStream(fileoutputstream, true);  printstream.println(name.toLowerCase()); printstream.println(password); printstream.println(""); printstream.println("---REGITEMS---");  printstream.println("rights=(LONG)" + Long.toString(rights)); printstream.println("color=(STRING)" + color); printstream.println("lastlogin=(STRING)" + lastlogin);   for(Enumeration e = props.keys(); e.hasMoreElements();) { String key = (String)e.nextElement(); Object value = props.get(key); String to_write = key + "="; if(value instanceof String) to_write += "(STRING)" +  (String)value; else if(value instanceof Long) to_write += "(LONG)" + ((Long)value).toString(); else to_write += "(STRING)" + value.toString();  printstream.println(to_write); } }  return true; }
    public boolean convert()    {        // set up the users hashtable        Hashtable users = new Hashtable();        // set up the two directories        File dir = new File(m_dir);        File dir1 = new File("old" + m_dir);        // check if dir1 exists, if yes delete it        if(dir1.exists())        {            System.out.println("old" + m_dir + " already exists! Deleting...");            if(dir1.isDirectory())                deleteFolder(dir1);            else                dir1.delete();        }        // rename dir to dir1 and create a new dir        dir.renameTo(dir1);        dir.mkdir();        // check for right permissions        if(!dir1.exists() || !dir1.isDirectory() || !dir1.canRead() || !dir1.canWrite())        {            System.out.println("Permission denied to " + dir1.getAbsolutePath() + ": Please check if you have the right permissions.");            return false;        }        // get file list        String reglist[] = dir1.list();        // declare all user variables        String name;        String password;        long rights;        String color;        String lastlogin;        Hashtable props;        String line;        for(int i = 0; i < reglist.length; ++i)        {            String file = reglist[i];            FileInputStream fileinputstream = null;            try            {                fileinputstream = new FileInputStream(dir1.getAbsolutePath() + "/" + file);            }            catch(java.io.FileNotFoundException e)            {                System.out.println("Error opening " + file + "! Continue with next file...");                continue;            }            BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(fileinputstream));            name = "";            password = "";            rights = 0;            color = "";            lastlogin = "";            props = new Hashtable();            line = "";            // read in name and password            name = bufferedreader.readLine();            password = bufferedreader.readLine();            // check for null pointer            if(name == null || password == null)            {                System.out.println("Damaged file " + file + " - skipping...");                continue;            }            // read in next line            line = bufferedreader.readLine();            // check for null pointer            if(line == null)            {                System.out.println("Damaged file " + file + " - skipping...");                continue;            }            // to do, if yace 1 file format            if(m_format == 1)            {                // read in next line (rights)                try                {                    rights = Long.parseLong(line);                }                catch(NumberFormatException e)                {                    rights = 0;                }                // read in next lines                color = bufferedreader.readLine();                lastlogin = bufferedreader.readLine();                // read in next line ("--REGITEMS--")                line = bufferedreader.readLine();                // check for null pointer                if(color == null || lastlogin == null || line == null)                {                    System.out.println("Damaged file " + file + " - skipping...");                    continue;                }                // check if line is "--REGITEMS--"                if(!line.equals("--REGITEMS--"))                {                    System.out.println("Damaged file " + file + " - skipping...");                    continue;                }                // read until file end                while((line = bufferedreader.readLine()) != null)                {                    // split the line by "="                    String[] split = line.split("=", 2);                    // check if array size is right                    if(split.length != 2)                    {                        System.out.println("Damaged file " + file + " - skipping...");                        continue;                    }                    // put the regitem into the props hashtable                    props.put("reginfo_" + split[1], split[2]);                }            }            // to do, if yace 2 file format            else            {                // read next line                line = bufferedreader.readLine();                // check for null pointer and if string equals "---REGITEMS---"                if(line == null || !line.equals("---REGITEMS---"))                {                    System.out.println("Damaged file " + file + " - skipping...");                    continue;                }                // read until file end                while((line = bufferedreader.readLine()) != null)                {                    // split the line by "="                    String[] split = line.split("=", 2);                    if(split.length != 2)                    {                        System.out.println("Damaged file " + file + " - skipping...");                        continue;                    }                    // if a reginfo was found                    if(split[1].startsWith("reg_"))                    {                        // cut the " out of the second part of the line                        // replace the "reg_" with "reginfo_"                        props.put("reginfo_" + split[1].substring(4), split[2].substring(1, split[2].length() - 1));                    }                    // if regitem rights was found                    else if(split[1].equals("rights"))                    {                        try                        {                            rights = Long.parseLong(split[2]);                        }                        catch(NumberFormatException e)                        {                            rights = 0;                        }                    }                    // if regitem color was found                    else if(split[1].equals("color"))                    {                        // cut the " out of the second part of the line                        color = split[2].substring(1, split[2].length() - 1);                    }                    // if regitem lastlogin was found                    else if(split[1].equals("lastlogin"))                    {                        // cut the " out of the second part of the line                        lastlogin = split[2].substring(1, split[2].length() - 1);                    }                    else                    {                        // check if string                        if(split[2].startsWith("\"") && split[2].endsWith("\""))                        {                            // cut the " out of the second part of the line                            props.put(split[1], split[2].substring(1, split[2].length() - 1));                        }                        // if long                        else                        {                            try                            {                                props.put(split[1], new Long(split[2]));                            }                            catch(NumberFormatException e)                            {                            }                        }                    }                }            }// write            System.out.println("name = " + name);            System.out.println("password = " + name);            System.out.println("rights = " + Long.toString(rights));            System.out.println("color = " + name);            System.out.println("lastlogin = " + name);            System.out.println();            for(Enumeration e = props.keys(); e.hasMoreElements();)            {                String key = (String)e.nextElement();                Object value = props.get(key);                System.out.println(key + " = " + value.toString());            }            System.out.println();            System.out.println();            // open file output            /* FileOutputStream fileoutputstream = null;            try            {                fileoutputstream = new FileOutputStream(m_dir + "/" + name.toLowerCase() + ".yrf");            }            catch(java.io.FileNotFoundException e)            {                System.out.println("Error opening " + name + ".yrf! Continue with next file...");                continue;            }            PrintStream printstream = new PrintStream(fileoutputstream, true);            printstream.println(name.toLowerCase());            printstream.println(password);            printstream.println("");            printstream.println("---REGITEMS---");            for(Enumeration e = props.keys(); e.hasMoreElements();)            {                String key = (String)e.nextElement();                Object value = props.get(key);                String to_write = key + "=";                if(value instanceof String)                    to_write += "(STRING)\"" +  (String)value + "\"";                else if(value instanceof Long)                    to_write += "(LONG)\"" + ((Long)value).toString() + "\"";                else                    to_write += "(STRING)\"" + value.toString() + "\"";                printstream.println(to_write);            } */        }        return true;    }