Tabnine Logo
uk.ac.ebi.intact.commons.util
Code IndexAdd Tabnine to your IDE (free)

How to use uk.ac.ebi.intact.commons.util

Best Java code snippets using uk.ac.ebi.intact.commons.util (Showing top 20 results out of 315)

origin: uk.ac.ebi.intact.commons/intact-commons

  /**
   * Print a user friendly time for estimated time of completion of the task.
   *
   * @param currentCount current count of unit processed.
   * @return a nicely formatted remaining time.
   */
  public String printETA( long currentCount ) {
    long eta = calculateETA( currentCount );
    return new ElapsedTime( ( int ) eta ).toString();
  }
}
origin: uk.ac.ebi.intact.commons/intact-commons

  public void run(){buildMemoryReport();
  }
}
origin: uk.ac.ebi.intact.commons/intact-commons

/**
 * Non-recursive listing of the files in a URL
 * @param folderUrl The folder to read
 * @return the lists of URLs
 * @throws java.io.IOException
 */
public static List<URL> listFilesFromFolderUrl(URL folderUrl) throws IOException
{
  return listFilesFromFolderUrl(folderUrl, null, false);
}
origin: uk.ac.ebi.intact.core/intact-core-readonly

public String crc64(Interaction interaction) {
  UniquenessStringBuilder sb = createUniquenessString(interaction);
  final String uniquenessString = sb.toString().toLowerCase();
  String crc64 = Crc64.getCrc64(uniquenessString);
  if (log.isDebugEnabled())
    log.debug("Created CRC for interaction '" + interaction.getShortLabel() + "': " + crc64 + " (" + uniquenessString + ")");
  return crc64;
}
origin: uk.ac.ebi.intact.commons/intact-commons

public static Collection<URL> searchResourcesInClasspath(String prefix, String suffix) throws IOException {
  return searchResourcesInClasspath(Thread.currentThread().getContextClassLoader(), prefix,
                   suffix);
}
origin: uk.ac.ebi.intact.commons/intact-commons

public static void zip( File[] sourceFiles, File destFile, boolean deleteOriginalFiles ) throws IOException {
  zip( sourceFiles, destFile, deleteOriginalFiles, false );
}
origin: uk.ac.ebi.intact.commons/intact-commons

@Override
public String toString() {
  if( hasTime() ) {
    return printTime( stop - start );
  } else {
    long current = System.currentTimeMillis();
    return printTime( current - start );
  }
}
origin: uk.ac.ebi.intact.commons/intact-commons

/**
 * Send a mail to a set of recipients.
 *
 * @param recipients list of mail adresses
 * @param subject    subject of the mail
 * @param message    content of the mail
 * @param from       who wrote that mail
 *
 * @throws javax.mail.MessagingException if the message can't be sent.
 */
public void postMail( String recipients[ ], String subject, String message, String from, File ... fileAttachments ) throws MessagingException {
  Session session = Session.getInstance(properties);
  postMail(session, recipients, subject, message, from, fileAttachments);
}
origin: uk.ac.ebi.intact.commons/intact-commons

/**
 * Uncompresses zipped files
 * @param zippedFile The file to uncompress
 * @return list of unzipped files
 * @throws java.io.IOException thrown if there is a problem finding or writing the files
 */
public static List<File> unzip(File zippedFile) throws IOException
{
  return unzip(zippedFile, null);
}
origin: uk.ac.ebi.intact.commons/intact-commons

public MemoryMonitor() {
  hook();
}
origin: uk.ac.ebi.intact.commons/intact-commons

/**
 * Zip the subdirectory and exclude already zipped files
 * @param path
 * @param srcFolder
 * @param zip
 * @param includeFullPath
 * @throws IOException
 */
static private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip, boolean includeFullPath) throws IOException {
  File folder = new File(srcFolder);
  for (String fileName : folder.list()) {
    if (path.equals("") && !fileName.endsWith(".zip")) {
      if (includeFullPath){
        addFileToZip(folder.toString(), srcFolder + "/" + fileName, zip);
      }
      else {
        addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip);
      }
    } else if (!fileName.endsWith(".zip")) {
      addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip);
    }
  }
}
origin: uk.ac.ebi.intact.commons/intact-commons

/**
 * @param resource      Name of resource(s) to find in classpath
 * @param defaultObject The default object to use to determine the class loader (if none associated with current thread.)
 *
 * @return Iterator over URL Objects
 */
public static Iterator<URL> getResources(String resource, Object defaultObject) throws IOException {
  Enumeration<URL> resources = getCurrentLoader(defaultObject).getResources(resource);
  List<URL> lst = new ArrayList<URL>();
  while (resources.hasMoreElements()) {
    lst.add(resources.nextElement());
  }
  return lst.iterator();
}
origin: uk.ac.ebi.intact.commons/intact-commons

protected static void searchDir(Set<URL> resultUrls, File dir, String suffix)
    throws IOException {
  if (dir.exists() && dir.isDirectory()) {
    File[] files = dir.listFiles();
    String absolutePath;
    for (File file : files) {
      absolutePath = file.getAbsolutePath();
      if (file.isDirectory()) {
        searchDir(resultUrls, file, suffix);
      } else if (absolutePath.endsWith(suffix)) {
        resultUrls.add(file.toURL());
      }
    }
  }
}
origin: uk.ac.ebi.intact.commons/intact-commons

static private void addFileToZip(String path, String srcFile, ZipOutputStream zip) throws IOException {
  File folder = new File(srcFile);
  if (folder.isDirectory()) {
    addFolderToZip(path, srcFile, zip, false);
  } else {
    byte[] buf = new byte[1024];
    int len;
    FileInputStream in = new FileInputStream(srcFile);
    try{
      zip.putNextEntry(new ZipEntry(path + "/" + folder.getName()));
      while ((len = in.read(buf)) > 0) {
        zip.write(buf, 0, len);
      }
    }
    finally {
      in.close();
    }
  }
}
origin: uk.ac.ebi.intact.core/intact-core

public String crc64(Interaction interaction) {
  UniquenessStringBuilder sb = createUniquenessString(interaction);
  final String uniquenessString = sb.toString().toLowerCase();
  String crc64 = Crc64.getCrc64(uniquenessString);
  if (log.isDebugEnabled())
    log.debug("Created CRC for interaction '" + interaction.getShortLabel() + "': " + crc64 + " (" + uniquenessString + ")");
  return crc64;
}
origin: uk.ac.ebi.intact.commons/intact-commons

public static Collection<URL> searchResourcesInClasspath(String resourcePath) throws IOException {
  return searchResourcesInClasspath(Thread.currentThread().getContextClassLoader(), resourcePath, "");
}
origin: uk.ac.ebi.intact.commons/intact-commons

/**
 * Send a mail to a set of recipients.
 *
 * @param recipients list of mail adresses
 * @param subject    subject of the mail
 * @param message    content of the mail
 * @param from       who wrote that mail
 *
 * @throws javax.mail.MessagingException if the message can't be sent.
 */
public void postMail( String recipients[ ], String subject, String message, String from ) throws MessagingException {
  Session session = Session.getInstance(properties);
  postMail(session, recipients, subject, message, from, null);
}
origin: uk.ac.ebi.intact.sanity/intact-sanity-commons

protected void loadDeclaredRulesFromClassPath() throws IOException {
  Collection<URL> resources = ClassUtils.searchResourcesInClasspath( RULES_XML_PATH );
  if ( log.isDebugEnabled() )
    log.debug( "Found " + resources.size() + " sanity-rules.xml files in the classpath" );
  if ( log.isDebugEnabled() && resources.size() > 1 ) {
    int i = 1;
    for ( URL resource : resources ) {
      log.debug( i + ") " + resource.getFile() );
      i++;
    }
  }
  for ( URL resource : resources ) {
    try {
      DeclaredRules dr = readDeclaredRules( resource.openStream() );
      addAllDeclaredRules( dr.getDeclaredRules() );
      if ( log.isDebugEnabled() )
        log.debug( "Loaded " + dr.getDeclaredRules().size() + " declared rules from: " + resource );
    } catch ( Throwable t ) {
      throw new SanityRuleException( "Problem reading declared rules from resource: " + resource, t );
    }
  }
}
origin: uk.ac.ebi.intact.commons/intact-commons

/**
 * Send a mail to a set of recipients.
 *
 * @param recipients list of mail adresses
 * @param subject    subject of the mail
 * @param message    content of the mail
 * @param from       who wrote that mail
 *
 * @throws javax.mail.MessagingException if the message can't be sent.
 */
public void postMailSSL( String recipients[ ], String subject, String message, String from, final PasswordAuthentication auth, File ... fileAttachment ) throws MessagingException {
  Session session = Session.getDefaultInstance(properties,
      new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
          return auth;
        }
      });
  postMail(session, recipients, subject, message, from, fileAttachment);
}
origin: uk.ac.ebi.intact.commons/intact-commons

/**
 * Send a mail to a set of recipients.
 *
 * @param recipients list of mail adresses
 * @param subject    subject of the mail
 * @param message    content of the mail
 * @param from       who wrote that mail
 *
 * @throws javax.mail.MessagingException if the message can't be sent.
 */
public void postMailSSL( String recipients[ ], String subject, String message, String from, final PasswordAuthentication auth ) throws MessagingException {
  Session session = Session.getDefaultInstance(properties,
      new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
          return auth;
        }
      });
  postMail(session, recipients, subject, message, from, null);
}
uk.ac.ebi.intact.commons.util

Most used classes

  • Crc64
    Crc64 checksum computation.
  • UrlFilter
    Filter for URLs
  • ClassUtils
  • CompressionUtils
    Various IntAct related utilities. If a pice of code is used more than once, but does not really belo
  • Chrono
  • ETACalculator,
  • ElapsedTime,
  • MailSender,
  • MemoryMonitor,
  • UrlUtils,
  • Diff,
  • DiffCalculator,
  • Operation,
  • diff_match_patch$Diff,
  • diff_match_patch$Patch,
  • diff_match_patch
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now