private static int getBuildNumber(File installDirectory) {
    installDirectory = installDirectory.getAbsoluteFile();

    File buildTxt = new File(installDirectory, BUILD_NUMBER_FILE);
    if ((!buildTxt.exists()) || (buildTxt.isDirectory())) {
      buildTxt = new File(new File(installDirectory, BIN_FOLDER), BUILD_NUMBER_FILE);
    }

    if (buildTxt.exists() && !buildTxt.isDirectory()) {
      int buildNumber = -1;
      String buildNumberText = getContent(buildTxt);
      if (buildNumberText != null) {
        try {
          if (buildNumberText.length() > 1) {
            buildNumberText = buildNumberText.trim();
            buildNumber = Integer.parseInt(buildNumberText);
          }
        } catch (Exception e) {
          // OK
        }
      }
      return buildNumber;
    }

    return -1;
  }
Ejemplo n.º 2
0
    public void valueChanged(ListSelectionEvent evt) {
      if (!evt.getValueIsAdjusting()) {
        JFileChooser chooser = getFileChooser();
        FileSystemView fsv = chooser.getFileSystemView();
        JList list = (JList) evt.getSource();

        int fsm = chooser.getFileSelectionMode();
        boolean useSetDirectory = usesSingleFilePane && (fsm == JFileChooser.FILES_ONLY);

        if (chooser.isMultiSelectionEnabled()) {
          File[] files = null;
          Object[] objects = list.getSelectedValues();
          if (objects != null) {
            if (objects.length == 1
                && ((File) objects[0]).isDirectory()
                && chooser.isTraversable(((File) objects[0]))
                && (useSetDirectory || !fsv.isFileSystem(((File) objects[0])))) {
              setDirectorySelected(true);
              setDirectory(((File) objects[0]));
            } else {
              ArrayList<File> fList = new ArrayList<File>(objects.length);
              for (Object object : objects) {
                File f = (File) object;
                boolean isDir = f.isDirectory();
                if ((chooser.isFileSelectionEnabled() && !isDir)
                    || (chooser.isDirectorySelectionEnabled() && fsv.isFileSystem(f) && isDir)) {
                  fList.add(f);
                }
              }
              if (fList.size() > 0) {
                files = fList.toArray(new File[fList.size()]);
              }
              setDirectorySelected(false);
            }
          }
          chooser.setSelectedFiles(files);
        } else {
          File file = (File) list.getSelectedValue();
          if (file != null
              && file.isDirectory()
              && chooser.isTraversable(file)
              && (useSetDirectory || !fsv.isFileSystem(file))) {

            setDirectorySelected(true);
            setDirectory(file);
            if (usesSingleFilePane) {
              chooser.setSelectedFile(null);
            }
          } else {
            setDirectorySelected(false);
            if (file != null) {
              chooser.setSelectedFile(file);
            }
          }
        }
      }
    }
Ejemplo n.º 3
0
 public static void createDirectories() {
   final String[] dirs = {
     Paths.getHomeDirectory(),
     Paths.getLogsDirectory(),
     Paths.getCacheDirectory(),
     Paths.getSettingsDirectory(),
     Paths.getScriptsDirectory(),
     Paths.getScriptsSourcesDirectory(),
     Paths.getScriptsPrecompiledDirectory(),
     Paths.getScriptsNetworkDirectory(),
   };
   for (final String name : dirs) {
     final File dir = new File(name);
     if (!dir.isDirectory()) {
       dir.mkdirs();
     }
   }
   if (Configuration.getCurrentOperatingSystem() == Configuration.OperatingSystem.WINDOWS) {
     try {
       Runtime.getRuntime()
           .exec(
               "attrib +H \""
                   + new File(Paths.getScriptsNetworkDirectory()).getAbsolutePath()
                   + "\"");
     } catch (final IOException ignored) {
     }
   }
 }
Ejemplo n.º 4
0
 public boolean accept(File pathname) {
   if (pathname.isDirectory()) return true;
   else {
     if (pathname.getName().indexOf(".scl") != -1) return true;
     else return false;
   }
 }
Ejemplo n.º 5
0
  /** Initialize the panel UI component values from the current site profile settings. */
  public void updatePanel() {
    {
      File dir = pApp.getHomeDirectory();

      if (dir == null) {
        String home = System.getProperty("user.home");
        if (home != null) {
          File hdir = new File(home);
          if ((hdir != null) && hdir.isDirectory()) dir = hdir.getParentFile();
        }
      }

      if (dir == null) dir = new File("/home");

      pHomeDirComp.setDir(dir);
    }

    {
      File dir = pApp.getTemporaryDirectory();
      if (dir == null) dir = new File("/var/tmp");
      pTempDirComp.setDir(dir);
    }

    {
      File dir = pApp.getUnixJavaHome();
      if (dir == null) dir = new File(pApp.getJavaHome());
      pJavaHomeDirComp.setDir(dir);
    }

    pJavadocDirComp.setDir(pApp.getUnixLocalJavadocDirectory());
    pExtraJavaLibsComp.setJars(pApp.getUnixLocalJavaLibraries());
  }
Ejemplo n.º 6
0
 private void listFilesForFolder(final File folder) {
   for (final File fileEntry : folder.listFiles()) {
     if (fileEntry.isDirectory()) {
       listFilesForFolder(fileEntry);
     } else {
       Image img = new Image(fileEntry.toURI().toString());
       imgMan.images.add(
           new ImageInformation(
               img,
               fileEntry.toURI().toString(),
               new ImageInformation.Type[] {
                 ImageInformation.Type.SAND, ImageInformation.Type.FISH,
                 ImageInformation.Type.ALGA, ImageInformation.Type.CORAL,
                 ImageInformation.Type.SAND
               },
               new Point[] {
                 new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.25)),
                 new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.25)),
                 new Point((int) (img.getWidth() * 0.5), (int) (img.getHeight() * 0.5)),
                 new Point((int) (img.getWidth() * 0.25), (int) (img.getHeight() * 0.75)),
                 new Point((int) (img.getWidth() * 0.75), (int) (img.getHeight() * 0.75))
               },
               new double[] {0.86, 0.76, 0.99, 0.65, 0.54}));
     }
   }
 }
  protected void getImages() {
    File directory = new File(this.saveDirectory);

    // BufferedImage img = null;

    images = new ArrayList<String>();
    if (directory.exists() && directory.isDirectory()) {
      // File[] files = directory.listFiles();
      String[] files = directory.list();

      for (int i = 0; i < files.length; i++) {
        // System.out.println(files[i]);
        // try {
        // if(files[i].getName().startsWith("cam"))
        if (files[i].startsWith("cam")) {
          // Windows spesific
          images.add(this.saveDirectory + "\\" + files[i]);
          /*
          img = ImageIO.read(files[i]);
          images.add(img);*/
        }
        // } catch (IOException e) {
        //	System.err.println("Failed on reading image. IOException.");
        // }
      }
    }

    System.out.println("Total image count = " + images.size());
    gotImages = true;
  }
Ejemplo n.º 8
0
 public boolean accept(File f) {
   if (f == null) {
     return false;
   }
   if (f.isDirectory()) {
     return true;
   }
   return pattern.matcher(f.getName()).matches();
 }
Ejemplo n.º 9
0
 /**
  * The FileEvent listener.
  *
  * @param event the event.
  */
 public void fileEventOccurred(FileEvent event) {
   File file = event.getFile();
   if (file != null) {
     String dirPath;
     if (file.isDirectory()) dirPath = file.getAbsolutePath();
     else dirPath = file.getParentFile().getAbsolutePath();
     properties.setProperty("directory", dirPath);
   } else properties.remove("directory");
 }
Ejemplo n.º 10
0
 public void startFile(String logfile) {
   File parent = new File(logfile).getParentFile();
   if (!parent.isDirectory() && !parent.mkdirs()) {
     logger.warning("Could not create log folder: " + parent);
   }
   Handler fileHandler = new RotatingFileHandler(logfile);
   fileHandler.setFormatter(new DateOutputFormatter(FILE_DATE));
   logger.addHandler(fileHandler);
 }
Ejemplo n.º 11
0
 protected void fileNew() {
   if (currentFile != null) {
     if (!currentFile.isDirectory()) {
       currentFile = currentFile.getParentFile();
     }
   }
   graph.clear();
   gp.update(gp.getGraphics());
 }
Ejemplo n.º 12
0
 public String getTypeDescription(File f) {
   String type = getFileChooser().getFileSystemView().getSystemTypeDescription(f);
   if (type == null) {
     if (f.isDirectory()) {
       type = directoryDescriptionText;
     } else {
       type = fileDescriptionText;
     }
   }
   return type;
 }
Ejemplo n.º 13
0
 protected void fileSave() {
   if (currentFile == null) {
     fileSaveAs();
   } else {
     if (currentFile.isDirectory()) {
       fileSaveAs();
     } else {
       graph.saveAll(currentFile);
       gp.update(gp.getGraphics());
     }
   }
 }
Ejemplo n.º 14
0
  /** Returns false if Exception is thrown. */
  private boolean setDirectory() {
    String pathStr = dirTF.getText().trim();
    if (pathStr.equals("")) pathStr = System.getProperty("user.dir");
    try {
      File dirPath = new File(pathStr);
      if (!dirPath.isDirectory()) {
        if (!dirPath.exists()) {
          if (recursiveCheckBox.isSelected())
            throw new NotDirectoryException(dirPath.getAbsolutePath());
          else throw new NotFileException(dirPath.getAbsolutePath());
        } else {
          convertSet.setFile(dirPath);
          convertSet.setDestinationPath(dirPath.getParentFile());
        }
      } else {
        // Set the descriptors
        setMatchingFileNames();

        FlexFilter flexFilter = new FlexFilter();
        flexFilter.addDescriptors(descriptors);
        flexFilter.setFilesOnly(!recursiveCheckBox.isSelected());

        convertSet.setSourcePath(dirPath, flexFilter);
        convertSet.setDestinationPath(dirPath);
      }
    } catch (NotDirectoryException e1) {
      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption1");

      MessageFormat formatter;
      String info_msg;
      if (pathStr.equals("")) {
        info_msg = ResourceHandler.getMessage("notdirectory_dialog.info5");
      } else {
        formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info0"));
        info_msg = formatter.format(new Object[] {pathStr});
      }
      final String info = info_msg;

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    } catch (NotFileException e2) {
      final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption0");

      MessageFormat formatter =
          new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info1"));
      final String info = formatter.format(new Object[] {pathStr});

      JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE);
      return false;
    }

    return true; // no exception thrown
  }
  private boolean _assignValues(File fle) {
    String strMethod = "_assignValues(fle)";

    if (fle == null) {
      MySystem.s_printOutError(this, strMethod, "nil fle");
      return false;
    }

    if (!fle.exists()) {
      MySystem.s_printOutWarning(
          this, strMethod, "! fle.exists(), fle.getAbsolutePath()=" + fle.getAbsolutePath());

      String strBody = fle.getAbsolutePath();
      strBody += ":\nDirectory not found.";

      OPAbstract.s_showDialogWarning(super._frmParent_, strBody);

      return true;
    }

    if (!fle.isDirectory()) // statement should never be reached!!!
    {
      MySystem.s_printOutWarning(
          this, strMethod, "! fle.isDirectory(), fle.getAbsolutePath()=" + fle.getAbsolutePath());

      String strBody = fle.getAbsolutePath();
      strBody += ":\n  not a directory.";

      OPAbstract.s_showDialogWarning(super._frmParent_, strBody);

      return true;
    }

    if (super._tfdCurSelection_ == null) {
      MySystem.s_printOutError(this, strMethod, "nil super._tfdCurSelection_");
      return false;
    }

    super._tfdCurSelection_.setText(fle.getAbsolutePath());
    super._setSelectedValue_(true);

    if (!_enableButtonsSelectionDone_()) {
      MySystem.s_printOutError(this, strMethod, "failed");
      return false;
    }

    // --
    // ending
    return true;
  }
Ejemplo n.º 16
0
  /**
   * Enumerates the resouces in a give package name. This works even if the resources are loaded
   * from a jar file!
   *
   * <p>Adapted from code by mikewse on the java.sun.com message boards.
   * http://forum.java.sun.com/thread.jsp?forum=22&thread=30984
   *
   * @param packageName The package to enumerate
   * @return A Set of Strings for each resouce in the package.
   */
  public static Set getResoucesInPackage(String packageName) throws IOException {
    String localPackageName;
    if (packageName.endsWith("/")) {
      localPackageName = packageName;
    } else {
      localPackageName = packageName + '/';
    }

    Enumeration dirEnum = ClassLoader.getSystemResources(localPackageName);

    Set names = new HashSet();

    // Loop CLASSPATH directories
    while (dirEnum.hasMoreElements()) {
      URL resUrl = (URL) dirEnum.nextElement();

      // Pointing to filesystem directory
      if (resUrl.getProtocol().equals("file")) {
        File dir = new File(resUrl.getFile());
        File[] files = dir.listFiles();
        if (files != null) {
          for (int i = 0; i < files.length; i++) {
            File file = files[i];
            if (file.isDirectory()) continue;
            names.add(localPackageName + file.getName());
          }
        }

        // Pointing to Jar file
      } else if (resUrl.getProtocol().equals("jar")) {
        JarURLConnection jconn = (JarURLConnection) resUrl.openConnection();
        JarFile jfile = jconn.getJarFile();
        Enumeration entryEnum = jfile.entries();
        while (entryEnum.hasMoreElements()) {
          JarEntry entry = (JarEntry) entryEnum.nextElement();
          String entryName = entry.getName();
          // Exclude our own directory
          if (entryName.equals(localPackageName)) continue;
          String parentDirName = entryName.substring(0, entryName.lastIndexOf('/') + 1);
          if (!parentDirName.equals(localPackageName)) continue;
          names.add(entryName);
        }
      } else {
        // Invalid classpath entry
      }
    }

    return names;
  }
Ejemplo n.º 17
0
 public static boolean deleteAll(File file) {
   boolean b = true;
   if ((file != null) && file.exists()) {
     if (file.isDirectory()) {
       try {
         File[] files = file.listFiles();
         for (File f : files) b &= deleteAll(f);
       } catch (Exception e) {
         return false;
       }
     }
     b &= file.delete();
   }
   return b;
 }
Ejemplo n.º 18
0
    @Override
    public boolean accept(File file) {
      if (file.isDirectory()) {
        return true;
      }

      String name = file.getName().toLowerCase();
      for (int i = 0; i < extensions.length; ++i) {
        if (name.endsWith(extensions[i])) {
          return true;
        }
      }

      return false;
    }
Ejemplo n.º 19
0
  void addChildren(DefaultMutableTreeNode parent, File parentDirFile) {

    for (File file : parentDirFile.listFiles()) {
      String[] namesplitStrings = file.toString().split("\\\\");
      String filename = namesplitStrings[namesplitStrings.length - 1];

      if (file.isDirectory()) {
        DefaultMutableTreeNode child = new DefaultMutableTreeNode(filename);
        addChildren(child, file);
        parent.add(child);
      } else if (file.isFile()) {
        parent.add(new DefaultMutableTreeNode(filename));
      }
    }
  }
Ejemplo n.º 20
0
  public static void delete(File file) {
    if (file.isFile()) file.delete();

    File[] files = file.listFiles();
    if (files != null) { // some JVMs return null for empty dirs
      for (File f : files) {
        if (f.isDirectory()) {
          delete(f);
        } else {
          f.delete();
        }
      }
    }
    file.delete();
  }
Ejemplo n.º 21
0
  public static void main(String[] args) {
    // read arguments and respond correctly
    File in;
    File out;
    String tileDirectory;
    if (args.length == 0 || args.length > 2) {
      in = null;
      out = null;
      tileDirectory = "";
      System.err.println("Incorrect number of arguments. Required: Filename (tileset path)");
      System.exit(0);
    } else if (args.length == 1) { // load old file
      in = new File(args[0]);
      out = in;
      Scanner s = null;
      try {
        s = new Scanner(in);
      } catch (FileNotFoundException e) {
        System.out.println("Could not find input file.");
        System.exit(0);
      }
      tileDirectory = s.nextLine();
    } else {
      in = null;
      out = new File(args[0]);
      tileDirectory = args[1];
      try {
        File f = new File(tileDirectory);
        if (!f.isDirectory()) {
          throw new IOException("Tileset does not exist");
        }
      } catch (IOException e) {
        System.err.println(e);
        System.out.println("This error is likely thanks to an invalid tileset path");
        System.exit(0);
      }
    }

    MapBuilder test = new MapBuilder("Map Editor", in, out, tileDirectory);

    // Build GUI
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            test.CreateAndDisplayGUI();
          }
        });
  }
 @Test
 public void test_main_offline() throws IOException {
   File offline = new File("OfflineData.bin");
   if (offline.exists() && !offline.isDirectory()) {
     this.getLogger().info("OfflineData.bin file exists.");
     if (GraphicsEnvironment.isHeadless()) {
       this.binFileReader = new BinFileReader(offline);
     } else {
       this.binFileReader = new BinFileReaderGui(offline);
     }
     do_read_from_bin();
     System.out.println("");
   } else {
     getLogger().warning("No OfflineData.bin file!");
   }
 }
Ejemplo n.º 23
0
 protected void fileSaveSimple() {
   JFileChooser chooser = null;
   if (currentFile == null) {
     chooser = new JFileChooser(startDirectory);
   } else {
     chooser = new JFileChooser(currentFile);
     if (!currentFile.isDirectory()) {
       chooser.setSelectedFile(currentFile);
     }
   }
   int returnVal = chooser.showSaveDialog(gw);
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     currentFile = chooser.getSelectedFile();
     graph.saveSimple(currentFile);
   }
 }
Ejemplo n.º 24
0
  // returneaza true daca entry reprezinta un director si false in caz contrar
  public boolean isDirectory(String entry) {

    try {
      String targetPath = currentPath + "\\" + entry;
      File file = new File(targetPath);
      if (!file.exists()) System.out.println("Fisierul nu exista");
      if (file.isDirectory()) {
        System.out.println(entry + " este un director");
        return true;
      } else {
        System.out.println(entry + " nu este un director");
        return false;
      }
    } catch (Exception e) {
      return false;
    } finally {
      takePath();
    }
  }
Ejemplo n.º 25
0
  private void browseAction() {
    if (selectedPath == null) {
      selectedPath = System.getenv("ROPE_SOURCES_DIR");
      if (selectedPath != null) {
        File dir = new File(selectedPath);
        if (!dir.exists() || !dir.isDirectory()) {
          String message =
              String.format(
                  "The sources path set in environment variable ROPE_SOURCES_DIR is not avaliable.\n%s",
                  selectedPath);
          JOptionPane.showMessageDialog(null, message, "ROPE", JOptionPane.WARNING_MESSAGE);
          selectedPath = null;
        } else {
          System.out.println("Source folder path set from ROPE_SOURCES_DIR: " + selectedPath);
        }
      }
      if (selectedPath == null) {
        selectedPath = System.getProperty("user.dir");

        System.out.println("Source folder path set to current directory: " + selectedPath);
      }
    }

    Vector<RopeFileFilter> filters = new Vector<RopeFileFilter>();
    filters.add(
        new RopeFileFilter(
            new String[] {".a", ".asm", ".aut", ".s"}, "Assembly files (*.a *.asm *.aut *.s)"));
    filters.add(new RopeFileFilter(new String[] {".m", ".mac"}, "Macro files (*.m *.mac)"));
    filters.add(new RopeFileFilter(new String[] {".lst"}, "List files (*.lst)"));
    filters.add(new RopeFileFilter(new String[] {".txt"}, "Text files (*.txt)"));

    RopeFileChooser chooser = new RopeFileChooser(selectedPath, null, filters);
    chooser.setDialogTitle("Source document selection");
    chooser.setFileFilter(filters.firstElement());
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    File file = chooser.open(this, fileText);
    if (file != null) {
      if (loadSourceFile(file)) {
        mainFrame.showExecWindow(baseName);
      }
    }
  }
Ejemplo n.º 26
0
 /** Returns an InputStream for the image described by this FileInfo. */
 public InputStream createInputStream(FileInfo fi) throws IOException, MalformedURLException {
   InputStream is = null;
   boolean gzip =
       fi.fileName != null && (fi.fileName.endsWith(".gz") || fi.fileName.endsWith(".GZ"));
   if (fi.inputStream != null) is = fi.inputStream;
   else if (fi.url != null && !fi.url.equals("")) is = new URL(fi.url + fi.fileName).openStream();
   else {
     if (fi.directory.length() > 0 && !fi.directory.endsWith(Prefs.separator))
       fi.directory += Prefs.separator;
     File f = new File(fi.directory + fi.fileName);
     if (gzip) fi.compression = FileInfo.COMPRESSION_UNKNOWN;
     if (f == null || f.isDirectory() || !validateFileInfo(f, fi)) is = null;
     else is = new FileInputStream(f);
   }
   if (is != null) {
     if (fi.compression >= FileInfo.LZW) is = new RandomAccessStream(is);
     else if (gzip) is = new GZIPInputStream(is, 50000);
   }
   return is;
 }
Ejemplo n.º 27
0
 /**
  * Load the file names of all files in the given directory.
  *
  * @param dirName Directory (folder) name.
  * @param suffix File suffix of interest.
  * @return The names of files found.
  */
 private String[] findFiles(String dirName, String suffix) {
   File dir = new File(dirName);
   if (dir.isDirectory()) {
     String[] allFiles = dir.list();
     if (suffix == null) {
       return allFiles;
     } else {
       List<String> selected = new ArrayList<String>();
       for (String filename : allFiles) {
         if (filename.endsWith(suffix)) {
           selected.add(filename);
         }
       }
       return selected.toArray(new String[selected.size()]);
     }
   } else {
     System.out.println("Error: " + dirName + " must be a directory");
     return null;
   }
 }
Ejemplo n.º 28
0
  private File getHomeFile() {

    File home = null;
    java.util.List result = new java.util.ArrayList();
    String value = null;

    // -----------------------------------------------------------------
    // <bilder>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_HOME + "/" + TAG_BILDER);
    if (result.size() == 1) {
      value = ((Element) result.get(0)).getTextTrim();
      value = PM_Utils.removeLastSeparatorChar(value);
      home = new File(value);
      if (!home.isDirectory()) {
        home = null;
      }
    }
    return home;
  }
  public void generateInfluenceGraphs(List<String> result) {
    DownstreamTree tree =
        new DownstreamTree(
            travSt,
            travExp,
            new BranchDataProvider() {
              @Override
              public Color getColor(String gene, String root) {
                double pval = calcPVal(root, Collections.singleton(gene));

                String colS = val2Color(pval, calcChangeDirection(root, gene) ? 1 : -1);
                String[] c = colS.split(" ");
                return new Color(
                    Integer.parseInt(c[0]), Integer.parseInt(c[1]), Integer.parseInt(c[2]));
              }

              @Override
              public double getThickness(GeneBranch branch, String root) {
                Set<String> dwstr = branch.getAllGenes();
                double cumPval = calcPVal(root, dwstr);

                return Math.min(-Math.log(cumPval), 5);
              }
            });

    String dir = this.dir + dataset.name() + "/";
    File d = new File(dir);
    if (!d.exists()) d.mkdirs();
    assert d.isDirectory();

    for (String mut : result) {
      GeneBranch g = tree.getTree(mut, downstream.get(mut), depth);
      g.trimToMajorPaths(downstream.get(mut));
      if (g.selectLeaves(affectedDw.get(mut))) {
        if (!affectedDw.get(mut).isEmpty() && affectedDw.get(mut).size() < 6)
          RadialInfluenceTree.write(g.copy(true), false, dir + mut + ".svg");

        writeTree(g, dir);
      }
    }
  }
Ejemplo n.º 30
-1
  private void saveItem() {

    File f = new File("config.txt");

    if (f.exists() && !f.isDirectory()) {

      try (PrintWriter out =
          new PrintWriter(new BufferedWriter(new FileWriter("config.txt", true)))) {
        if (!searchName.getText().equals("") && !item.getText().equals("")) {

          out.println(
              searchName.getText()
                  + ","
                  + "http://www.reddit.com/r/hardwareswap/search?q="
                  + item.getText()
                  + "&sort=new&restrict_sr=on");
          addItem();

        } else {

          results.setText("Please provide all info for Search Name and Item");
        }

      } catch (IOException e1) {
        results.append("Error saving to file.");
      }

    } else {
      Main.checkFiles();
    }
  }