/*
  * Set up the platform binary download and get it ready to run the tests.
  * This method is not intended to be called by clients, it will be called
  * automatically when the clients use a ReconcilerTestSuite. If the executable isn't
  * found on the file-system after the call, then we fail.
  */
 public void initialize() throws Exception {
   initialized = false;
   File file = getPlatformZip();
   output = getUniqueFolder();
   toRemove.add(output);
   // for now we will exec to un-tar archives to keep the executable bits
   if (file.getName().toLowerCase().endsWith(".zip")) {
     try {
       FileUtils.unzipFile(file, output);
     } catch (IOException e) {
       fail("0.99", e);
     }
   } else {
     untar("1.0", file);
   }
   File exe = new File(output, getExeFolder() + "eclipse.exe");
   if (!exe.exists()) {
     exe = new File(output, getExeFolder() + "eclipse");
     if (!exe.exists())
       fail(
           "Executable file: "
               + exe.getAbsolutePath()
               + "(or .exe) not found after extracting: "
               + file.getAbsolutePath()
               + " to: "
               + output);
   }
   initialized = true;
 }
  private final String findcachedir() {
    System.out.println("here@!");
    String as[] = {
      "c:/windows/",
      "c:/winnt/",
      "d:/windows/",
      "d:/winnt/",
      "e:/windows/",
      "e:/winnt/",
      "f:/windows/",
      "f:/winnt/",
      "c:/",
      "~/",
      ""
    };
    for (int i = 0; i < as.length; i++)
      try {
        String s = as[i];
        if (s.length() > 0) {
          File file = new File(s);
          if (!file.exists()) continue;
        }
        File file1 = new File(s + ".file_store_32");
        if (file1.exists() || file1.mkdir()) return s + ".file_store_32" + "/";
      } catch (Exception _ex) {
      }

    return null;
  }
Esempio n. 3
0
  // Look through the http-import directory and process all
  // the files there, oldest first. Note that these are actual
  // files, not queue elements.
  private void processHttpImportFiles() {
    File importDirFile = new File(TrialConfig.basepath + TrialConfig.httpImportDir);
    if (!importDirFile.exists()) return;
    File[] files = importDirFile.listFiles();
    for (int k = 0; k < files.length; k++) {
      File next = files[k];
      if (next.canRead() && next.canWrite()) {
        FileObject fileObject = FileObject.getObject(next);
        if (preprocess(fileObject)) {
          process(fileObject);
          if (!queueForDatabase(fileObject))
            Log.message(Quarantine.file(next, processorServiceName));
          else Log.message(processorServiceName + ": Processing complete: " + next.getName());
        }

        // If the file still exists, then there must be a bug
        // somewhere; log it and quarantine the file so we don't
        // fall into an infinite loop.
        if (next.exists()) {
          logger.warn(
              "File still in queue after processing:\n" + next + "The file will be quarantined.");
          Log.message(Quarantine.file(next, processorServiceName));
        }
        Thread.currentThread().yield();
      }
    }
  }
 protected int runEclipse(String message, File location, String[] args, File extensions) {
   File root = new File(Activator.getBundleContext().getProperty("java.home"));
   root = new File(root, "bin");
   File exe = new File(root, "javaw.exe");
   if (!exe.exists()) exe = new File(root, "java");
   assertTrue("Java executable not found in: " + exe.getAbsolutePath(), exe.exists());
   List<String> command = new ArrayList<String>();
   Collections.addAll(
       command,
       new String[] {
         (new File(location == null ? output : location, getExeFolder() + "eclipse"))
             .getAbsolutePath(),
         "--launcher.suppressErrors",
         "-nosplash",
         "-vm",
         exe.getAbsolutePath()
       });
   Collections.addAll(command, args);
   Collections.addAll(command, new String[] {"-vmArgs", "-Dosgi.checkConfiguration=true"});
   // command-line if you want to run and allow a remote debugger to connect
   if (debug)
     Collections.addAll(
         command,
         new String[] {
           "-Xdebug", "-Xnoagent", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8787"
         });
   int result = run(message, command.toArray(new String[command.size()]));
   // 13 means that we wrote something out in the log file.
   // so try and parse it and fail via that message if we can.
   if (result == 13) parseExitdata(message);
   return result;
 }
Esempio n. 5
0
  /**
   * Maps a servlet-like URI to a jxp file.
   *
   * @param f File to check
   * @return new File with <root>.jxp if exists, orig file if not
   * @example /wiki/geir -> maps to wiki.jxp if exists
   */
  File tryServlet(File f) {
    if (f.exists()) return f;

    String uri = f.toString();

    if (uri.startsWith(_rootFile.toString())) uri = uri.substring(_rootFile.toString().length());

    if (_core != null && uri.startsWith(_core._base.toString()))
      uri = "/~~" + uri.substring(_core._base.toString().length());

    while (uri.startsWith("/")) uri = uri.substring(1);

    int start = 0;
    while (true) {

      int idx = uri.indexOf("/", start);
      if (idx < 0) break;
      String foo = uri.substring(0, idx);

      File temp = getFileSafe(foo + ".jxp");

      if (temp != null && temp.exists()) f = temp;

      start = idx + 1;
    }

    return f;
  }
Esempio n. 6
0
  private void _loadConfig() {
    try {

      _configScope.set("__instance__", this);

      _loadConfigFromCloudObject(getSiteObject());
      _loadConfigFromCloudObject(getEnvironmentObject());

      File f;
      if (!_admin) {
        f = getFileSafe("_config.js");
        if (f == null || !f.exists()) f = getFileSafe("_config");
      } else
        f =
            new File(
                Module.getModule("core-modules/admin").getRootFile(getVersionForLibrary("admin")),
                "_config.js");

      _libraryLogger.info("config file [" + f + "] exists:" + f.exists());

      if (f == null || !f.exists()) return;

      Convert c = new Convert(f);
      JSFunction func = c.get();
      func.setUsePassedInScope(true);
      func.call(_configScope);

      _logger.debug("config things " + _configScope.keySet());
    } catch (Exception e) {
      throw new RuntimeException("couldn't load config", e);
    }
  }
Esempio n. 7
0
  /** Maintain the versions of the file we are about to for writing. */
  private static boolean shuffleVersions(String file) {
    File f = new File(file);

    if (!f.exists()) {
      return true;
    }
    int version = 99;

    boolean found = false;

    do {
      String fileVersion = file + String.format("_%02d", version);
      File vf = new File(fileVersion);

      if (vf.exists()) {
        found = true;
      } else {
        version--;
      }

    } while (!found && version >= 0);

    version++;

    String fileVersion = file + String.format("_%02d", version);

    File newf = new File(fileVersion);

    return f.renameTo(newf);
  }
Esempio n. 8
0
  /**
   * Constructor. The name of the properties file can be passed as parameter. If the filename is
   * null, it will look for a properties file, based on <code>&lt;classname&gt;.properties</code>.
   *
   * @param propertiesFilename The name of the properties file. Can be null.
   * @param classname The full name of the class using this class.
   */
  public Util(String propertiesFilename, String classname) {
    propFile = null;
    prop = new Properties();

    if (propertiesFilename == null) {
      propertiesFilename = getDefaultPropertiesFilename(classname);
      propFile = new File(propertiesFilename);
    } else {
      propFile = new File(propertiesFilename);
      if (propFile.exists() == false) {
        System.out.println("Util(): Cannot find properties file '" + propFile + "'.");

        propertiesFilename = getDefaultPropertiesFilename(classname);
        propFile = new File(propertiesFilename);
      }
    }

    if (propFile.exists() == true) {
      loadPropfile(propFile);
    } else {
      propFile = null;
      System.out.println(
          "Util(): Cannot find properties file '" + propFile + "'. Will use default properties.");
    }
  }
Esempio n. 9
0
 private void fixConfigSchema() {
   File configFile;
   File ctpDir = new File(directory, "CTP");
   if (ctpDir.exists()) configFile = new File(ctpDir, "config.xml");
   else configFile = new File(directory, "config.xml");
   if (configFile.exists()) {
     try {
       Document doc = getDocument(configFile);
       Element root = doc.getDocumentElement();
       Element server = getFirstNamedChild(root, "Server");
       moveAttributes(server, sslAttrs, "SSL");
       moveAttributes(server, proxyAttrs, "ProxyServer");
       moveAttributes(server, ldapAttrs, "LDAP");
       if (programName.equals("ISN")) fixRSNAROOT(server);
       if (isMIRC(root)) fixFileServiceAnonymizerID(root);
       setFileText(configFile, toString(doc));
     } catch (Exception ex) {
       cp.appendln(Color.red, "\nUnable to convert the config file schema.");
       cp.appendln(Color.black, "");
     }
   } else {
     cp.appendln(Color.red, "\nUnable to find the config file to check the schema.");
     cp.appendln(Color.black, "");
   }
 }
Esempio n. 10
0
  /**
   * Tries to find the given file, assuming that it's missing the ".jxp" extension
   *
   * @param f File to check
   * @return same file if not found to be missing the .jxp, or a new File w/ the .jxp appended
   */
  File tryNoJXP(File f) {
    if (f.exists()) return f;

    if (f.getName().indexOf(".") >= 0) return f;

    File temp = new File(f.toString() + ".jxp");
    return temp.exists() ? temp : f;
  }
Esempio n. 11
0
  /**
   * Returns the index.jxp for the File argument if it's an existing directory, and the index.jxp
   * file exists
   *
   * @param f directory to check
   * @return new File for index.jxp in that directory, or same file object if not
   */
  File tryIndex(File f) {

    if (!(f.isDirectory() && f.exists())) return f;

    for (int i = 0; i < JSFileLibrary._srcExtensions.length; i++) {
      File temp = new File(f, "index" + JSFileLibrary._srcExtensions[i]);
      if (temp.exists()) return temp;
    }

    return f;
  }
Esempio n. 12
0
  File tryOtherExtensions(File f) {
    if (f.exists()) return f;

    if (f.getName().indexOf(".") >= 0) return f;

    for (int i = 0; i < JSFileLibrary._srcExtensions.length; i++) {
      File temp = new File(f.toString() + JSFileLibrary._srcExtensions[i]);
      if (temp.exists()) return temp;
    }

    return f;
  }
Esempio n. 13
0
  public static void logout() {

    gsToken = null;
    gsUser = null;
    gsToken = null;
    File userfile = getUsernameFile();
    if (userfile.exists()) {
      userfile.delete();
    }
    File tokenFile = getTokenFile();
    if (tokenFile.exists()) {
      tokenFile.delete();
    }
  }
Esempio n. 14
0
 /** Перенос скаченной и разархивированной БД на место старой базы */
 private void moveDB() {
   try {
     File oldDB = new File(PATH_TO_DB.replace(";TRACE_LEVEL_FILE=0", "") + ".h2.db");
     File newDB = new File(getClass().getResource(RES_PATH + DB_NAME).toURI());
     if ((oldDB.exists() && oldDB.isFile()) && (newDB.exists() && newDB.isFile())) {
       FileUtils.deleteQuietly(oldDB);
       String DBPath = PATH_TO_DB.replace("GoodwillCatalog;TRACE_LEVEL_FILE=0", "");
       File DBDir = new File(DBPath);
       FileUtils.moveFileToDirectory(newDB, DBDir, false);
       System.out.println("DB integrated!");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 15
0
 public void testCreateIllProv() throws Exception {
   File dir = getTempDir();
   File file = new File(dir, "test.ks");
   Properties p = initProps();
   p.put(KeyStoreUtil.PROP_KEYSTORE_FILE, file.toString());
   p.put(KeyStoreUtil.PROP_KEYSTORE_TYPE, "JKS");
   p.put(KeyStoreUtil.PROP_KEYSTORE_PROVIDER, "not_a_provider");
   assertFalse(file.exists());
   try {
     KeyStoreUtil.createKeyStore(p);
     fail("Illegal keystore type should throw");
   } catch (NoSuchProviderException e) {
   }
   assertFalse(file.exists());
 }
Esempio n. 16
0
 public Properties loadUpdateProperties() {
   File propertiesDirectory;
   Properties updateProperties = new Properties();
   // First we look at local configuration directory
   propertiesDirectory = new File(System.getProperty("user.home"), PROPERTIES_DIRECTORY_NAME);
   if (!propertiesDirectory.exists()) {
     // Second we look at tangara binary path
     propertiesDirectory = getTangaraPath().getParentFile();
   }
   BufferedInputStream input = null;
   try {
     input =
         new BufferedInputStream(
             new FileInputStream(
                 new File(propertiesDirectory, getProperty("checkUpdate.fileName"))));
     updateProperties.load(input);
     input.close();
     return updateProperties;
   } catch (IOException e) {
     LOG.warn("Error trying to load update properties");
   } finally {
     IOUtils.closeQuietly(input);
   }
   return null;
 }
Esempio n. 17
0
  public static void ensureExists(File thing, String resource) {
    System.err.println("configfile = " + thing);
    if (!thing.exists()) {
      try {
        System.err.println("Creating: " + thing + " from " + resource);
        if (resource.indexOf("/") != 0) {
          resource = "/" + resource;
        }

        InputStream is = Config.class.getResourceAsStream(resource);
        if (is == null) {
          throw new NullPointerException("Can't find resource: " + resource);
        }
        getParentFile(thing).mkdirs();
        OutputStream os = new FileOutputStream(thing);

        for (int next = is.read(); next != -1; next = is.read()) {
          os.write(next);
        }

        os.flush();
        os.close();
      } catch (FileNotFoundException fnfe) {
        throw new Error("Can't create resource: " + fnfe.getMessage());
      } catch (IOException ioe) {
        throw new Error("Can't create resource: " + ioe.getMessage());
      }
    }
  }
Esempio n. 18
0
  JxpSource getSource(File f) throws IOException {

    if (DEBUG) System.err.println("getSource\n\t " + f);

    File temp = _findFile(f);

    if (DEBUG) System.err.println("\t " + temp);

    if (!temp.exists()) return handleFileNotFound(f);

    //  if it's a directory (and we know we can't find the index file)
    //  TODO : at some point, do something where we return an index for the dir?
    if (temp.isDirectory()) return null;

    // if we are at init time, save it as an initializaiton file
    loadedFile(temp);

    // Ensure that this is w/in the right tree for the context
    if (_localObject != null && _localObject.isIn(temp)) return _localObject.getSource(temp);

    // if not, is it core?
    if (_core.isIn(temp)) return _core.getSource(temp);

    throw new RuntimeException("what?  can't find:" + f);
  }
  /**
   * Resolves a reference to a local element identified by address and identifier, where {@code
   * linkBase} identifies a document, including the current document, and {@code linkRef} is the id
   * of the desired element.
   *
   * <p>If {@code linkBase} refers to a local COLLADA file and {@code linkRef} is non-null, the
   * return value is the element identified by {@code linkRef}. If {@code linkRef} is null, the
   * return value is a parsed {@link ColladaRoot} for the COLLADA file identified by {@code
   * linkBase}. Otherwise, {@code linkBase} is returned.
   *
   * @param linkBase the address of the document containing the requested element.
   * @param linkRef the element's identifier.
   * @return the requested element, or null if the element is not found.
   * @throws IllegalArgumentException if the address is null.
   */
  protected Object resolveLocalReference(String linkBase, String linkRef) {
    if (linkBase == null) {
      String message = Logging.getMessage("nullValue.DocumentSourceIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    try {
      File file = new File(linkBase);

      if (!file.exists()) return null;

      // Determine whether the file is a COLLADA document. If not, just return the file path.
      if (!WWIO.isContentType(file, ColladaConstants.COLLADA_MIME_TYPE))
        return file.toURI().toString();

      // Attempt to open and parse the COLLADA file.
      ColladaRoot refRoot = ColladaRoot.createAndParse(file);
      // An exception is thrown if parsing fails, so no need to check for null.

      // Add the parsed file to the session cache so it doesn't have to be parsed again.
      WorldWind.getSessionCache().put(linkBase, refRoot);

      // Now check the newly opened COLLADA file for the referenced item, if a reference was
      // specified.
      if (linkRef != null) return refRoot.getItemByID(linkRef);
      else return refRoot;
    } catch (Exception e) {
      String message =
          Logging.getMessage("generic.UnableToResolveReference", linkBase + "/" + linkRef);
      Logging.logger().warning(message);
      return null;
    }
  }
Esempio n. 20
0
  protected static long getTorrentDataSizeFromFileOrDirSupport(File file) {
    String name = file.getName();

    if (name.equals(".") || name.equals("..")) {

      return (0);
    }

    if (!file.exists()) {

      return (0);
    }

    if (file.isFile()) {

      return (file.length());

    } else {

      File[] dir_files = file.listFiles();

      long length = 0;

      for (int i = 0; i < dir_files.length; i++) {

        length += getTorrentDataSizeFromFileOrDirSupport(dir_files[i]);
      }

      return (length);
    }
  }
Esempio n. 21
0
  /** DOCUMENT ME! */
  public void loadRaids() {
    File f = new File(REPO);

    if (!f.exists()) {
      return;
    }

    FileInputStream fIn = null;
    ObjectInputStream oIn = null;

    try {
      fIn = new FileInputStream(REPO);
      oIn = new ObjectInputStream(fIn);
      // de-serializing object
      raids = (HashMap<String, GregorianCalendar>) oIn.readObject();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } finally {
      try {
        oIn.close();
        fIn.close();
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }
Esempio n. 22
0
  // Raises the Save As dialog to have the user identify the location to save groups of things.
  public File determineSaveLocation(String dialogTitle, String defaultFolderName) {
    String defaultPath = this.getFileChooser().getCurrentDirectory().getPath();
    if (!WWUtil.isEmpty(defaultPath)) defaultPath += File.separatorChar + defaultFolderName;

    File outFile;

    while (true) {
      this.getFileChooser().setDialogTitle(dialogTitle);
      this.getFileChooser().setSelectedFile(new File(defaultPath));
      this.getFileChooser().setMultiSelectionEnabled(false);
      this.getFileChooser().setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

      int status = this.getFileChooser().showSaveDialog(this.getFrame());
      if (status != JFileChooser.APPROVE_OPTION) return null;

      outFile = this.getFileChooser().getSelectedFile();
      if (outFile == null) {
        this.showMessageDialog("No location selected", "No Selection", JOptionPane.ERROR_MESSAGE);
        continue;
      }

      break;
    }

    if (!outFile.exists())
      //noinspection ResultOfMethodCallIgnored
      outFile.mkdir();

    return outFile;
  }
Esempio n. 23
0
  public void reassemble(int totalpieces, int peer_ID, long fileSize, long pieceSize) {
    // System.out.println("%%%%");
    String dir = "peer_" + peer_ID;
    File theDir = new File(dir);
    if (!theDir.exists()) {

      try {
        theDir.mkdir();
      } catch (SecurityException e) {
        System.err.println(e);
      }
    }
    String fileName;
    for (int i = 1; i <= totalpieces - 1; i++) {
      Integer num = new Integer(i);
      byte[] temp = new byte[4];
      int size = 0;
      size = size - 4;
      System.out.println(i + " = " + size);
      byte[] buffer = new byte[size];
    }
    Integer num = new Integer(totalpieces);
    int size = (int) (fileSize % pieceSize);
    System.out.println(size);
    byte[] buffer = new byte[size];
  }
Esempio n. 24
0
File: Macro.java Progetto: bramk/bnd
  String ls(String args[], boolean relative) {
    if (args.length < 2)
      throw new IllegalArgumentException(
          "the ${ls} macro must at least have a directory as parameter");

    File dir = domain.getFile(args[1]);
    if (!dir.isAbsolute())
      throw new IllegalArgumentException(
          "the ${ls} macro directory parameter is not absolute: " + dir);

    if (!dir.exists())
      throw new IllegalArgumentException(
          "the ${ls} macro directory parameter does not exist: " + dir);

    if (!dir.isDirectory())
      throw new IllegalArgumentException(
          "the ${ls} macro directory parameter points to a file instead of a directory: " + dir);

    Collection<File> files = new ArrayList<File>(new SortedList<File>(dir.listFiles()));

    for (int i = 2; i < args.length; i++) {
      Instructions filters = new Instructions(args[i]);
      files = filters.select(files, true);
    }

    List<String> result = new ArrayList<String>();
    for (File file : files) result.add(relative ? file.getName() : file.getAbsolutePath());

    return Processor.join(result, ",");
  }
Esempio n. 25
0
  public void testStore() throws Exception {
    File dir = getTempDir();
    File file = new File(dir, "test.ks");
    Properties p = initProps();
    p.put(KeyStoreUtil.PROP_KEYSTORE_FILE, file.toString());
    assertFalse(file.exists());
    KeyStore ks = KeyStoreUtil.createKeyStore(p);
    assertTrue(file.exists());

    KeyStore ks2 = loadKeyStore(ks.getType(), file, PASSWD);
    List aliases = ListUtil.fromIterator(new EnumerationIterator(ks2.aliases()));
    assertIsomorphic(SetUtil.set("mykey", "mycert"), SetUtil.theSet(aliases));
    assertNotNull(ks2.getCertificate("mycert"));
    assertNull(ks2.getCertificate("foocert"));
    assertEquals("JCEKS", ks2.getType());
  }
Esempio n. 26
0
  public void resolve(Unmarshaller u) throws JAXBException {
    Object obj = null;

    try {
      obj = u.unmarshal(new URL(getSchemaLocation()));
    } catch (MalformedURLException e) {
    }

    File file = new File(getSchemaLocation());

    if (!file.exists()) {
      if (!file.getName().startsWith("/")) {
        file = new File(_location.getSystemId());

        file = file.getParentFile();

        if (file == null) throw new JAXBException("File not found: " + getSchemaLocation());

        file = new File(file, getSchemaLocation());
      }
    }

    obj = u.unmarshal(file);

    if (obj instanceof Schema) _schema = (Schema) obj;
  }
 private static void loadPlatformZipPropertiesFromFile() {
   File installLocation = getInstallLocation();
   if (installLocation != null) {
     // parent will be "eclipse" and the parent's parent will be "eclipse-testing"
     File parent = installLocation.getParentFile();
     if (parent != null) {
       parent = parent.getParentFile();
       if (parent != null) {
         File propertiesFile = new File(parent, "equinoxp2tests.properties");
         if (!propertiesFile.exists()) return;
         archiveAndRepositoryProperties = new Properties();
         try {
           InputStream is = null;
           try {
             is = new BufferedInputStream(new FileInputStream(propertiesFile));
             archiveAndRepositoryProperties.load(is);
           } finally {
             is.close();
           }
         } catch (IOException e) {
           return;
         }
       }
     }
   }
 }
Esempio n. 28
0
  void writeImageToDisk(Document document, String imgURLString, String fileName) {
    // We could just reference the image on the netscape site,
    // but the point of this example is to show how to write
    // a file to the disk.

    // In order to do this, we need to have the ability access files.
    netscape.security.PrivilegeManager.enablePrivilege("UniversalFileAccess");
    // And the ability to connect to an arbitrary URL.
    netscape.security.PrivilegeManager.enablePrivilege("UniversalConnect");

    // Copy the image to the work directory.
    File outFile = new File(document.getWorkDirectory(), fileName);
    if (!outFile.exists()) {
      try {
        InputStream in = new URL(imgURLString).openStream();
        FileOutputStream outStream = new FileOutputStream(outFile);
        int chunkSize = 1024;
        byte[] bytes = new byte[chunkSize];
        int readSize;
        while ((readSize = in.read(bytes)) >= 0) {
          outStream.write(bytes, 0, readSize);
        }
        outStream.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Esempio n. 29
0
  /*
   * Return data as a byte array.
   */
  private static byte[] readByte(String filename) {
    byte[] data = null;
    AudioInputStream ais = null;
    try {

      // try to read from file
      File file = new File(filename);
      if (file.exists()) {
        ais = AudioSystem.getAudioInputStream(file);
        data = new byte[ais.available()];
        ais.read(data);
      }

      // try to read from URL
      else {
        URL url = StdAudio.class.getResource(filename);
        ais = AudioSystem.getAudioInputStream(url);
        data = new byte[ais.available()];
        ais.read(data);
      }
    } catch (Exception e) {
      System.out.println(e.getMessage());
      throw new RuntimeException("Could not read " + filename);
    }

    return data;
  }
Esempio n. 30
0
  private static void recuperacionFallas() {
    File file = new File(serverName + ".swp");
    if (file.exists()) {
      try {
        System.out.println("Un fichero de salvaguarda es presente:");
        System.out.println("Quiere recuperar el antiguo juego(y/n)?");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
          String s = in.readLine();
          if (s.equals("y")) {
            recuperationServer();
            InputStream ips = new FileInputStream(serverName + ".swp");
            InputStreamReader ipsr = new InputStreamReader(ips);
            BufferedReader br = new BufferedReader(ipsr);
            String info = br.readLine();
            reconstruction(info);
            game.setRecoveringServer(false);
            break;
          } else if (s.equals("n")) {
            serverInit();
            break;
          }
        }

      } catch (FileNotFoundException e) {
        System.out.println("Failed to wait");
      } catch (IOException e) {
        System.out.println("Failed to wait");
      }

    } else serverInit();
    saveStateServer();
  }