Exemplo n.º 1
0
  /**
   * This method loads the network.
   *
   * @return The network
   */
  public Network loadNetwork() {
    Network ret = null;

    try {
      java.io.InputStream is = NetworkLoader.class.getResourceAsStream(NETWORK_FILE);

      byte[] b = new byte[is.available()];
      is.read(b);

      is.close();

      ret = NetworkUtil.deserialize(b);

    } catch (Exception e) {
      e.printStackTrace();
    }

    return (ret);
  }
Exemplo n.º 2
0
  /**
   * The main method.
   *
   * @param args The list of args
   */
  public static void main(String[] args) {
    NetworkLoader loader = new NetworkLoader();

    Network net = loader.createNetwork();

    try {
      byte[] b = NetworkUtil.serialize(net);

      java.net.URL url = NetworkLoader.class.getResource(NETWORK_FILE);

      java.io.FileOutputStream fos = new java.io.FileOutputStream(url.getFile());

      fos.write(b);
      fos.flush();

      fos.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }