Esempio n. 1
0
  // Function use to load all Records from File when Application Execute.
  void populateArray() {

    try {
      fis = new FileInputStream("Bank.dat");
      dis = new DataInputStream(fis);
      // Loop to Populate the Array.
      while (true) {
        for (int i = 0; i < 6; i++) {
          records[rows][i] = dis.readUTF();
        }
        rows++;
      }
    } catch (Exception ex) {
      total = rows;
      if (total == 0) {
        JOptionPane.showMessageDialog(
            null,
            "Records File is Empty.\nEnter Records First to Display.",
            "BankSystem - EmptyFile",
            JOptionPane.PLAIN_MESSAGE);
        btnEnable();
      } else {
        try {
          dis.close();
          fis.close();
        } catch (Exception exp) {
        }
      }
    }
  }
  public static Pair<String[], int[]> listAll(int parentId) {
    try {
      r.lock();
      try {
        final DataInputStream input = readAttribute(parentId, CHILDREN_ATT);
        if (input == null)
          return Pair.create(ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.EMPTY_INT_ARRAY);

        final int count = DataInputOutputUtil.readINT(input);
        final int[] ids = ArrayUtil.newIntArray(count);
        final String[] names = ArrayUtil.newStringArray(count);
        for (int i = 0; i < count; i++) {
          int id = DataInputOutputUtil.readINT(input);
          id = id >= 0 ? id + parentId : -id;
          ids[i] = id;
          names[i] = getName(id);
        }
        input.close();
        return Pair.create(names, ids);
      } finally {
        r.unlock();
      }
    } catch (Throwable e) {
      throw DbConnection.handleError(e);
    }
  }
  private static void checkAttributesSanity(
      final int attributeRecordId,
      final IntArrayList usedAttributeRecordIds,
      final IntArrayList validAttributeIds)
      throws IOException {
    assert !usedAttributeRecordIds.contains(attributeRecordId);
    usedAttributeRecordIds.add(attributeRecordId);

    final DataInputStream dataInputStream = getAttributesStorage().readStream(attributeRecordId);
    try {
      while (dataInputStream.available() > 0) {
        int attId = DataInputOutputUtil.readINT(dataInputStream);
        int attDataRecordId = DataInputOutputUtil.readINT(dataInputStream);
        assert !usedAttributeRecordIds.contains(attDataRecordId);
        usedAttributeRecordIds.add(attDataRecordId);
        if (!validAttributeIds.contains(attId)) {
          assert getNames().valueOf(attId).length() > 0;
          validAttributeIds.add(attId);
        }
        getAttributesStorage().checkSanity(attDataRecordId);
      }
    } finally {
      dataInputStream.close();
    }
  }
Esempio n. 4
0
 // --------------------------------------------------
 public void close() {
   try {
     is.close();
     os.close();
     socket.close();
     responseArea.appendText("***Connection closed" + "\n");
   } catch (IOException e) {
     responseArea.appendText("IO Exception" + "\n");
   }
 }
Esempio n. 5
0
 // Close socket and IO streams, change appearance/functionality of some components
 private void closeAll() throws IOException {
   displayArea.append("\nConnection closing");
   output.close();
   input.close();
   connection.close();
   // We are no longer connected
   connection = null;
   // Change components
   serverField.setEditable(true);
   connectButton.setLabel("Connect to server above");
   enterField.setEnabled(false);
 }
  public static int findRootRecord(String rootUrl) throws IOException {
    try {
      w.lock();
      DbConnection.markDirty();
      final int root = getNames().enumerate(rootUrl);

      final DataInputStream input = readAttribute(1, CHILDREN_ATT);
      int[] names = ArrayUtil.EMPTY_INT_ARRAY;
      int[] ids = ArrayUtil.EMPTY_INT_ARRAY;

      if (input != null) {
        try {
          final int count = DataInputOutputUtil.readINT(input);
          names = ArrayUtil.newIntArray(count);
          ids = ArrayUtil.newIntArray(count);
          for (int i = 0; i < count; i++) {
            final int name = DataInputOutputUtil.readINT(input);
            final int id = DataInputOutputUtil.readINT(input);
            if (name == root) {
              return id;
            }

            names[i] = name;
            ids[i] = id;
          }
        } finally {
          input.close();
        }
      }

      final DataOutputStream output = writeAttribute(1, CHILDREN_ATT, false);
      int id;
      try {
        id = createRecord();
        DataInputOutputUtil.writeINT(output, names.length + 1);
        for (int i = 0; i < names.length; i++) {
          DataInputOutputUtil.writeINT(output, names[i]);
          DataInputOutputUtil.writeINT(output, ids[i]);
        }
        DataInputOutputUtil.writeINT(output, root);
        DataInputOutputUtil.writeINT(output, id);
      } finally {
        output.close();
      }

      return id;
    } finally {
      w.unlock();
    }
  }
Esempio n. 7
0
  @Override
  public void actionPerformed(ActionEvent ev) {
    if (ev.getSource() == btn) {
      File file;
      String string = "";
      try {
        if (radioRead.isSelected()) {
          file = new File(txt.getText());
          DataInputStream input = new DataInputStream(new FileInputStream(file));
          int inByte;
          while ((inByte = input.read()) != -1) {
            string += (char) inByte;
          }
          input.close();

        } else if (radioEncrypt.isSelected()) {
          string = fileContent.getOut();
          String strEncrypt = new String();
          for (int i = 0; i < string.length(); i++) {
            char ch = string.charAt(i);
            if (ch >= 'A' && ch <= 'Z') {
              ch += 13;
              if (ch > 'Z') {
                ch -= 26;
              }
            } else if (ch >= 'a' && ch <= 'z') {
              ch += 13;
              if (ch > 'z') {
                ch -= 26;
              }
            }
            strEncrypt += ch;
          }
          string = strEncrypt;
        }

        if (fileContent == null) {
          fileContent = new FileContent(string);
        } else {
          fileContent.setVisible(true);
          fileContent.setOut(string);
        }

      } catch (FileNotFoundException e) {
        JOptionPane.showMessageDialog(this, "Can't find the file.");
      } catch (IOException e) {
        JOptionPane.showMessageDialog(this, "IO Exception " + e.getMessage());
      }
    }
  }
Esempio n. 8
0
  public void nick_name(String msg) {
    try {
      String name = msg.substring(13);
      this.setName(name);
      Vector v = father.onlineList;
      boolean isRepeatedName = false;
      int size = v.size();
      for (int i = 0; i < size; i++) {
        ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
        if (tempSat.getName().equals(name)) {
          isRepeatedName = true;
          break;
        }
      }
      if (isRepeatedName == true) {
        dout.writeUTF("<#NAME_REPEATED#>");
        din.close();
        dout.close();
        sc.close();
        flag = false;
      } else {
        v.add(this);
        father.refreshList();
        String nickListMsg = "";
        StringBuilder nickListMsgSb = new StringBuilder();
        size = v.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
          nickListMsgSb.append("!");
          nickListMsgSb.append(tempSat.getName());
        }
        nickListMsgSb.append("<#NICK_LIST#>");
        nickListMsg = nickListMsgSb.toString();
        Vector tempv = father.onlineList;
        size = tempv.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) tempv.get(i);
          tempSat.dout.writeUTF(nickListMsg);
          if (tempSat != this) {
            tempSat.dout.writeUTF("<#MSG#>" + this.getName() + "is now online....");
          }
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  private static void deleteContentAndAttributes(int id) throws IOException {
    int content_page = getContentRecordId(id);
    if (content_page != 0) {
      getContentStorage().releaseRecord(content_page);
    }

    int att_page = getAttributeRecordId(id);
    if (att_page != 0) {
      final DataInputStream attStream = getAttributesStorage().readStream(att_page);
      while (attStream.available() > 0) {
        DataInputOutputUtil.readINT(attStream); // Attribute ID;
        int attAddress = DataInputOutputUtil.readINT(attStream);
        getAttributesStorage().deleteRecord(attAddress);
      }
      attStream.close();
      getAttributesStorage().deleteRecord(att_page);
    }
  }
  private static int findAttributePage(int fileId, String attrId, boolean toWrite)
      throws IOException {
    checkFileIsValid(fileId);

    Storage storage = getAttributesStorage();

    int encodedAttrId = DbConnection.getAttributeId(attrId);
    int recordId = getAttributeRecordId(fileId);

    if (recordId == 0) {
      if (!toWrite) return 0;

      recordId = storage.createNewRecord();
      setAttributeRecordId(fileId, recordId);
    } else {
      DataInputStream attrRefs = storage.readStream(recordId);
      try {
        while (attrRefs.available() > 0) {
          final int attIdOnPage = DataInputOutputUtil.readINT(attrRefs);
          final int attrAddress = DataInputOutputUtil.readINT(attrRefs);

          if (attIdOnPage == encodedAttrId) return attrAddress;
        }
      } finally {
        attrRefs.close();
      }
    }

    if (toWrite) {
      Storage.AppenderStream appender = storage.appendStream(recordId);
      DataInputOutputUtil.writeINT(appender, encodedAttrId);
      int attrAddress = storage.createNewRecord();
      DataInputOutputUtil.writeINT(appender, attrAddress);
      DbConnection.REASONABLY_SMALL.myAttrPageRequested = true;
      try {
        appender.close();
      } finally {
        DbConnection.REASONABLY_SMALL.myAttrPageRequested = false;
      }
      return attrAddress;
    }

    return 0;
  }
Esempio n. 11
0
  public void readFile() throws IOException {
    try {

      FileInputStream fstream = new FileInputStream("dataIn.txt");
      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));

      String strLine;
      int memi = -1;
      int strLineMemory = 59;

      while ((strLine = br.readLine()) != null) {

        t.data[strLineMemory++][1] = String.valueOf(strLine);
        memi++;

        size++;
        while ((strLine = br.readLine()) != null && !strLine.startsWith("*")) {

          String[] arr = strLine.split(" ");
          String command = arr[0];
          String operand = arr[1];

          toMemory(command, operand, memarray[memi]);
          memarray[memi] = memarray[memi] + 2;
          System.out.printf("%s %s ", command, operand);
        }
      }

      in.close();
    } catch (Exception e) { // Catch exception if any
      System.err.println("Error: " + e.getMessage());
    }

    MOSMain mos = new MOSMain();
    mos.planner();

    t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    t.setSize(830, 800);
    t.setVisible(true);
    t.setTitle("Printer");
    sortTime();
  }
Esempio n. 12
0
  private final byte[] loadfile(String s, byte abyte0[]) {
    try {
      File file = new File(s);
      System.out.println("trying to load:" + file);
      int i = (int) file.length();
      DataInputStream datainputstream = new DataInputStream(new FileInputStream(s));
      byte abyte1[] = new byte[i];
      datainputstream.readFully(abyte1, 0, i);
      datainputstream.close();
      m.reset();
      m.update(abyte1);
      byte abyte2[] = m.digest();
      for (int j = 0; j < 20; j++) if (abyte2[j] != abyte0[j]) return null;

      return abyte1;
    } catch (Exception _ex) {
      return null;
    }
  }
Esempio n. 13
0
  // {{{ handleClient() method
  private boolean handleClient(final Socket client, DataInputStream in) throws Exception {
    int key = in.readInt();
    if (key != authKey) {
      Log.log(
          Log.ERROR,
          this,
          client + ": wrong" + " authorization key (got " + key + ", expected " + authKey + ")");
      in.close();
      client.close();

      return false;
    } else {
      // Reset the timeout
      client.setSoTimeout(0);

      Log.log(Log.DEBUG, this, client + ": authenticated" + " successfully");

      final String script = in.readUTF();
      Log.log(Log.DEBUG, this, script);

      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              try {
                NameSpace ns = new NameSpace(BeanShell.getNameSpace(), "EditServer namespace");
                ns.setVariable("socket", client);
                BeanShell.eval(null, ns, script);
              } catch (org.gjt.sp.jedit.bsh.UtilEvalError e) {
                Log.log(Log.ERROR, this, e);
              } finally {
                try {
                  BeanShell.getNameSpace().setVariable("socket", null);
                } catch (org.gjt.sp.jedit.bsh.UtilEvalError e) {
                  Log.log(Log.ERROR, this, e);
                }
              }
            }
          });

      return true;
    }
  } // }}}
  public static void deleteRootRecord(int id) throws IOException {
    try {
      w.lock();
      DbConnection.markDirty();
      final DataInputStream input = readAttribute(1, CHILDREN_ATT);
      assert input != null;
      int count;
      int[] names;
      int[] ids;
      try {
        count = DataInputOutputUtil.readINT(input);

        names = ArrayUtil.newIntArray(count);
        ids = ArrayUtil.newIntArray(count);
        for (int i = 0; i < count; i++) {
          names[i] = DataInputOutputUtil.readINT(input);
          ids[i] = DataInputOutputUtil.readINT(input);
        }
      } finally {
        input.close();
      }

      final int index = ArrayUtil.find(ids, id);
      assert index >= 0;

      names = ArrayUtil.remove(names, index);
      ids = ArrayUtil.remove(ids, index);

      final DataOutputStream output = writeAttribute(1, CHILDREN_ATT, false);
      try {
        DataInputOutputUtil.writeINT(output, count - 1);
        for (int i = 0; i < names.length; i++) {
          DataInputOutputUtil.writeINT(output, names[i]);
          DataInputOutputUtil.writeINT(output, ids[i]);
        }
      } finally {
        output.close();
      }
    } finally {
      w.unlock();
    }
  }
Esempio n. 15
0
 private final int getuid(String s) {
   try {
     File file = new File(s + "uid.dat");
     if (!file.exists() || file.length() < 4L) {
       DataOutputStream dataoutputstream =
           new DataOutputStream(new FileOutputStream(s + "uid.dat"));
       dataoutputstream.writeInt((int) (Math.random() * 99999999D));
       dataoutputstream.close();
     }
   } catch (Exception _ex) {
   }
   try {
     DataInputStream datainputstream = new DataInputStream(new FileInputStream(s + "uid.dat"));
     int i = datainputstream.readInt();
     datainputstream.close();
     return i + 1;
   } catch (Exception _ex) {
     return 0;
   }
 }
  public static int[] listRoots() throws IOException {
    try {
      r.lock();
      final DataInputStream input = readAttribute(1, CHILDREN_ATT);
      if (input == null) return ArrayUtil.EMPTY_INT_ARRAY;

      try {
        final int count = DataInputOutputUtil.readINT(input);
        int[] result = ArrayUtil.newIntArray(count);
        for (int i = 0; i < count; i++) {
          DataInputOutputUtil.readINT(input); // Name
          result[i] = DataInputOutputUtil.readINT(input); // Id
        }
        return result;
      } finally {
        input.close();
      }
    } finally {
      r.unlock();
    }
  }
Esempio n. 17
0
  /**
   * Reads an image from an archived file and return it as ByteBuffer object.
   *
   * @author Mike Butler, Kiet Le
   */
  private ByteBuffer readImage(String filename, Dimension dim) {
    if (dim == null) dim = new Dimension(0, 0);
    ByteBuffer bytes = null;
    try {
      DataInputStream dis =
          new DataInputStream(getClass().getClassLoader().getResourceAsStream(filename));
      dim.width = dis.readInt();
      dim.height = dis.readInt();
      System.out.println("Creating buffer, width: " + dim.width + " height: " + dim.height);
      // byte[] buf = new byte[3 * dim.height * dim.width];
      bytes = BufferUtil.newByteBuffer(3 * dim.width * dim.height);
      for (int i = 0; i < bytes.capacity(); i++) {
        bytes.put(dis.readByte());
      }
      dis.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
    bytes.rewind();
    return bytes;
  }
  public static int[] list(int id) {
    try {
      r.lock();
      try {
        final DataInputStream input = readAttribute(id, CHILDREN_ATT);
        if (input == null) return ArrayUtil.EMPTY_INT_ARRAY;

        final int count = DataInputOutputUtil.readINT(input);
        final int[] result = ArrayUtil.newIntArray(count);
        for (int i = 0; i < count; i++) {
          int childId = DataInputOutputUtil.readINT(input);
          childId = childId >= 0 ? childId + id : -childId;
          result[i] = childId;
        }
        input.close();
        return result;
      } finally {
        r.unlock();
      }
    } catch (Throwable e) {
      throw DbConnection.handleError(e);
    }
  }
Esempio n. 19
0
  public void loadState(String extension) {
    String directory = cartridge.romFileName + extension;

    try {
      reset();

      FileInputStream fl = new FileInputStream(directory);
      DataInputStream sv = new DataInputStream(fl);

      // write cpu data
      loadData(sv, directory);

      // write battery ram
      cartridge.loadData(sv, directory);

      // write graphic memory
      graphicsChip.loadData(sv, directory);

      // writes io state
      ioHandler.loadData(sv, directory);

      sv.close();
      fl.close();

    } catch (FileNotFoundException ex) {
      System.out.println("Dmgcpu.loadState: Could not open file " + directory);
      System.out.println("Error Message: " + ex.getMessage());
      System.exit(-1);
    } catch (IOException ex) {
      System.out.println("Dmgcpu.loadState: Could not read file " + directory);
      System.out.println("Error Message: " + ex.getMessage());
      System.exit(-1);
    }

    System.out.println("Loaded stage!");
  }
Esempio n. 20
0
  public final void run() {
    if (socketthread) {
      socketrun();
      return;
    }
    socketthread = true;
    try {
      boolean flag = false;
      try {
        String s = getParameter("member");
        int i = Integer.parseInt(s);
        if (i == 1) flag = true;
      } catch (Exception _ex) {
      }
      loading = getImage(new URL(getCodeBase(), "loading.jpg"));
      mt = new MediaTracker(this);
      mt.addImage(loading, 0);
      m = MessageDigest.getInstance("SHA");
      System.out.println(link.class);
      String s1 = ".file_store_32/";
      if (s1 == null) return;
      link.uid = getuid(s1);
      link.mainapp = this;
      link.numfile = 0;
      for (int j = 0; j < 14; j++)
        if (flag || !internetname[j].endsWith(".mem")) {
          for (int k = 0; k < 4; k++) {
            if (k == 3) return;
            byte abyte0[] = loadfile(s1 + localname[j], sha[j]);
            if (abyte0 != null) {
              if (j > 0) link.putjag(internetname[j], abyte0);
              break;
            }
            try {
              URL url = new URL(getCodeBase(), internetname[j]);
              DataInputStream datainputstream = new DataInputStream(url.openStream());
              int l = size[j];
              byte abyte1[] = new byte[l];
              for (int i1 = 0; i1 < l; i1 += 1000) {
                int j1 = l - i1;
                if (j1 > 1000) j1 = 1000;
                datainputstream.readFully(abyte1, i1, j1);
                showpercent(nicename[j], (i1 * 100) / l, barpos[j]);
              }

              datainputstream.close();
              FileOutputStream fileoutputstream = new FileOutputStream(s1 + localname[j]);
              fileoutputstream.write(abyte1);
              fileoutputstream.close();
            } catch (Exception _ex) {
            }
          }
        }
      System.out.println(cloader.class);
      cloader cloader1 = new cloader();
      cloader1.zip = new ZipFile(s1 + localname[0]);
      cloader1.link = Class.forName("link");
      inner = new mudclient_Debug();
      loadMacros();
      // inner = (Applet)cloader1.loadClass("mudclient").newInstance();
      inner.init();
      inner.start();
      return;
    } catch (Exception exception) {
      System.out.println(exception + " " + exception.getMessage());
      exception.printStackTrace();
      return;
    }
  }
Esempio n. 21
0
  // Run selected test cases.
  private void runTests() {

    for (int i = 0; i < tests.size(); i++) {
      // If box for test is checked, run it.
      if (tests.get(i).isSelected()) {

        // Get the URLs of all of the required files.
        String folderURL = tests.get(i).getText();
        String testURL = folderURL.concat(folderURL.substring(folderURL.lastIndexOf('/')));
        String efgFile = testURL + ".EFG";
        String guiFile = testURL + ".GUI";
        String tstFile = testURL + ".TST";
        String prgFile = testURL + ".PRG";

        // attempt to read in file with program's parameters
        try {
          FileInputStream fstream = new FileInputStream(prgFile);
          DataInputStream in = new DataInputStream(fstream);
          BufferedReader br = new BufferedReader(new InputStreamReader(in));
          HashMap<String, String> prgParams = new HashMap<String, String>();
          String strLine;
          while ((strLine = br.readLine()) != null) {
            // add found parameters into prgParams as <key, value>
            String[] matches = strLine.split("=");
            prgParams.put(matches[0], matches[1]);
          }

          if (prgParams.containsKey("path") && prgParams.containsKey("main")) {
            programPath = prgParams.get("path");
            mainClass = prgParams.get("main");
          }

          in.close();
        } catch (Exception e) {
          System.err.println(e.getMessage());
        }

        System.out.println("We hit Run");

        // Run the replayer using the three test files.
        System.out.println(
            "../../../dist/guitar/jfc-replayer.sh -cp "
                + programPath
                + " -c "
                + mainClass
                + " -g "
                + guiFile
                + " -e "
                + efgFile
                + " -t "
                + tstFile);
        try {
          Runtime rt = Runtime.getRuntime();
          Process proc =
              rt.exec(
                  "../../../dist/guitar/jfc-replayer.sh -cp "
                      + programPath
                      + " -c "
                      + mainClass
                      + " -g "
                      + guiFile
                      + " -e "
                      + efgFile
                      + " -t "
                      + tstFile);

          // InputStream ips = proc.getInputStream();
          BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
          String inputLine;
          while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
          in.close();

        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
Esempio n. 22
0
  /** devSetupGameState. */
  public static void devSetupGameState() {
    String t_humanLife = "-1";
    String t_computerLife = "-1";
    String t_humanSetupCardsInPlay = "NONE";
    String t_computerSetupCardsInPlay = "NONE";
    String t_humanSetupCardsInHand = "NONE";
    String t_computerSetupCardsInHand = "NONE";
    String t_humanSetupGraveyard = "NONE";
    String t_computerSetupGraveyard = "NONE";
    String t_humanSetupLibrary = "NONE";
    String t_computerSetupLibrary = "NONE";
    String t_humanSetupExile = "NONE";
    String t_computerSetupExile = "NONE";
    String t_changePlayer = "NONE";
    String t_changePhase = "NONE";

    String wd = ".";
    JFileChooser fc = new JFileChooser(wd);
    int rc = fc.showDialog(null, "Select Game State File");
    if (rc != JFileChooser.APPROVE_OPTION) return;

    try {
      FileInputStream fstream = new FileInputStream(fc.getSelectedFile().getAbsolutePath());
      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));

      String temp = "";

      while ((temp = br.readLine()) != null) {
        String[] temp_data = temp.split("=");

        if (temp_data.length < 2) continue;
        if (temp_data[0].toCharArray()[0] == '#') continue;

        String categoryName = temp_data[0];
        String categoryValue = temp_data[1];

        if (categoryName.toLowerCase().equals("humanlife")) t_humanLife = categoryValue;
        else if (categoryName.toLowerCase().equals("ailife")) t_computerLife = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsinplay"))
          t_humanSetupCardsInPlay = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsinplay"))
          t_computerSetupCardsInPlay = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsinhand"))
          t_humanSetupCardsInHand = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsinhand"))
          t_computerSetupCardsInHand = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsingraveyard"))
          t_humanSetupGraveyard = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsingraveyard"))
          t_computerSetupGraveyard = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsinlibrary"))
          t_humanSetupLibrary = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsinlibrary"))
          t_computerSetupLibrary = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsinexile"))
          t_humanSetupExile = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsinexile"))
          t_computerSetupExile = categoryValue;
        else if (categoryName.toLowerCase().equals("activeplayer")) t_changePlayer = categoryValue;
        else if (categoryName.toLowerCase().equals("activephase")) t_changePhase = categoryValue;
      }

      in.close();
    } catch (FileNotFoundException fnfe) {
      JOptionPane.showMessageDialog(
          null, "File not found: " + fc.getSelectedFile().getAbsolutePath());
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "Error loading battle setup file!");
      return;
    }

    int setHumanLife = Integer.parseInt(t_humanLife);
    int setComputerLife = Integer.parseInt(t_computerLife);

    String humanSetupCardsInPlay[] = t_humanSetupCardsInPlay.split(";");
    String computerSetupCardsInPlay[] = t_computerSetupCardsInPlay.split(";");
    String humanSetupCardsInHand[] = t_humanSetupCardsInHand.split(";");
    String computerSetupCardsInHand[] = t_computerSetupCardsInHand.split(";");
    String humanSetupGraveyard[] = t_humanSetupGraveyard.split(";");
    String computerSetupGraveyard[] = t_computerSetupGraveyard.split(";");
    String humanSetupLibrary[] = t_humanSetupLibrary.split(";");
    String computerSetupLibrary[] = t_computerSetupLibrary.split(";");
    String humanSetupExile[] = t_humanSetupExile.split(";");
    String computerSetupExile[] = t_computerSetupExile.split(";");

    CardList humanDevSetup = new CardList();
    CardList computerDevSetup = new CardList();
    CardList humanDevHandSetup = new CardList();
    CardList computerDevHandSetup = new CardList();
    CardList humanDevGraveyardSetup = new CardList();
    CardList computerDevGraveyardSetup = new CardList();
    CardList humanDevLibrarySetup = new CardList();
    CardList computerDevLibrarySetup = new CardList();
    CardList humanDevExileSetup = new CardList();
    CardList computerDevExileSetup = new CardList();

    if (!t_changePlayer.trim().toLowerCase().equals("none")) {
      if (t_changePlayer.trim().toLowerCase().equals("human")) {
        AllZone.getPhase().setPlayerTurn(AllZone.getHumanPlayer());
      }
      if (t_changePlayer.trim().toLowerCase().equals("ai")) {
        AllZone.getPhase().setPlayerTurn(AllZone.getComputerPlayer());
      }
    }

    if (!t_changePhase.trim().toLowerCase().equals("none")) {
      AllZone.getPhase().setDevPhaseState(t_changePhase);
    }

    if (!t_humanSetupCardsInPlay.trim().toLowerCase().equals("none"))
      humanDevSetup = devProcessCardsForZone(humanSetupCardsInPlay, AllZone.getHumanPlayer());

    if (!t_humanSetupCardsInHand.trim().toLowerCase().equals("none"))
      humanDevHandSetup = devProcessCardsForZone(humanSetupCardsInHand, AllZone.getHumanPlayer());

    if (!t_computerSetupCardsInPlay.trim().toLowerCase().equals("none"))
      computerDevSetup =
          devProcessCardsForZone(computerSetupCardsInPlay, AllZone.getComputerPlayer());

    if (!t_computerSetupCardsInHand.trim().toLowerCase().equals("none"))
      computerDevHandSetup =
          devProcessCardsForZone(computerSetupCardsInHand, AllZone.getComputerPlayer());

    if (!t_computerSetupGraveyard.trim().toLowerCase().equals("none"))
      computerDevGraveyardSetup =
          devProcessCardsForZone(computerSetupGraveyard, AllZone.getComputerPlayer());

    if (!t_humanSetupGraveyard.trim().toLowerCase().equals("none"))
      humanDevGraveyardSetup =
          devProcessCardsForZone(humanSetupGraveyard, AllZone.getHumanPlayer());

    if (!t_humanSetupLibrary.trim().toLowerCase().equals("none"))
      humanDevLibrarySetup = devProcessCardsForZone(humanSetupLibrary, AllZone.getHumanPlayer());

    if (!t_computerSetupLibrary.trim().toLowerCase().equals("none"))
      computerDevLibrarySetup =
          devProcessCardsForZone(computerSetupLibrary, AllZone.getComputerPlayer());

    if (!t_humanSetupExile.trim().toLowerCase().equals("none"))
      humanDevExileSetup = devProcessCardsForZone(humanSetupExile, AllZone.getHumanPlayer());

    if (!t_computerSetupExile.trim().toLowerCase().equals("none"))
      computerDevExileSetup =
          devProcessCardsForZone(computerSetupExile, AllZone.getComputerPlayer());

    AllZone.getTriggerHandler().suppressMode("ChangesZone");

    for (Card c : humanDevSetup) {
      AllZone.getHumanHand().add(c);
      AllZone.getGameAction().moveToPlay(c);
      c.setSickness(false);
    }

    for (Card c : computerDevSetup) {
      AllZone.getComputerHand().add(c);
      AllZone.getGameAction().moveToPlay(c);
      c.setSickness(false);
    }

    if (computerDevGraveyardSetup.size() > 0)
      AllZone.getComputerGraveyard().setCards(computerDevGraveyardSetup.toArray());
    if (humanDevGraveyardSetup.size() > 0)
      AllZone.getHumanGraveyard().setCards(humanDevGraveyardSetup.toArray());

    if (computerDevHandSetup.size() > 0)
      AllZone.getComputerHand().setCards(computerDevHandSetup.toArray());
    if (humanDevHandSetup.size() > 0) AllZone.getHumanHand().setCards(humanDevHandSetup.toArray());

    if (humanDevLibrarySetup.size() > 0)
      AllZone.getHumanLibrary().setCards(humanDevLibrarySetup.toArray());
    if (computerDevLibrarySetup.size() > 0)
      AllZone.getComputerLibrary().setCards(computerDevLibrarySetup.toArray());

    if (humanDevExileSetup.size() > 0)
      AllZone.getHumanExile().setCards(humanDevExileSetup.toArray());
    if (computerDevExileSetup.size() > 0)
      AllZone.getComputerExile().setCards(computerDevExileSetup.toArray());

    AllZone.getTriggerHandler().clearSuppression("ChangesZone");

    if (setComputerLife > 0) AllZone.getComputerPlayer().setLife(setComputerLife, null);
    if (setHumanLife > 0) AllZone.getHumanPlayer().setLife(setHumanLife, null);

    AllZone.getGameAction().checkStateEffects();
    AllZone.getPhase().updateObservers();
    AllZone.getHumanExile().updateObservers();
    AllZone.getComputerExile().updateObservers();
    AllZone.getHumanHand().updateObservers();
    AllZone.getComputerHand().updateObservers();
    AllZone.getHumanGraveyard().updateObservers();
    AllZone.getComputerGraveyard().updateObservers();
    AllZone.getHumanBattlefield().updateObservers();
    AllZone.getComputerBattlefield().updateObservers();
    AllZone.getHumanLibrary().updateObservers();
    AllZone.getComputerLibrary().updateObservers();
  }