Extract the previous segment id from a file name.

Note that the filename is assumed valid at this point.

@see parseFiles for file name structure
@param file
@return
340671
private long getPreviousSegmentId(File file) {
        PbdSegmentName segmentName = PbdSegmentName.parseFile(m_usageSpecificLog, file);
        if (segmentName.m_result != PbdSegmentName.Result.OK) {
            throw new IllegalStateException("Invalid file name: " + file.getName());
        }
        return segmentName.m_prevId;
    }
1298029
public static String getFileNameWithoutExtension(File file) {

		String name = file.getName();

		int extensionIndex = name.lastIndexOf(".");
		if (extensionIndex > -1) {
			name = name.substring(0, extensionIndex);
		}

		return name;
	}
428481
public static int getChunkId(String fileName) {
        Pattern pattern = Pattern.compile("_[\\d]+\\.");
        Matcher matcher = pattern.matcher(fileName);

        if(matcher.find()) {
            return new Integer(fileName.substring(matcher.start() + 1, matcher.end() - 1));
        } else {
            throw new VoldemortException("Could not extract out chunk id from " + fileName);
        }
    }
247502
public static String extName(File file) {
		if (null == file) {
			return null;
		}
		if (file.isDirectory()) {
			return null;
		}
		return extName(file.getName());
	}
1172712
private int getLastFileSeparator(String file) {
        if (file.contains("*") || file.contains("?")) {
            int p1 = file.indexOf('*');
            int p2 = file.indexOf('?');
            p1 = p1 > 0 ? p1 : file.length();
            p2 = p2 > 0 ? p2 : file.length();
            int pos = p1 < p2 ? p1 : p2;
            pos = file.lastIndexOf('/', pos);
            return pos;
        } else {
            return file.lastIndexOf('/');
        }
    }
67825
public static String parseProcessID(String fileName) {
        if (fileName == null || fileName.isEmpty()) {
            return null;
        }
        int pidIndex = fileName.indexOf(TIMESEPARATOR);
        int labelIndex = fileName.indexOf(LABELSEPARATOR);

        // If neither time separator or label separator present PID is the whole name
        if (pidIndex < 0 && labelIndex < 0) {
            return fileName;
        }

        // If no label separator then there's a time separator
        if (labelIndex < 0) {
            return fileName.substring(pidIndex + 1);
        }

        // If no time separator or it's a part of the label use label separator
        if (pidIndex < 0 || labelIndex < pidIndex) {
            return fileName.substring(0, labelIndex);
        }

        return fileName.substring(pidIndex + 1, labelIndex);
    }
291922
private String extractExtension(String filename) {
    int startExtension = filename.indexOf('.');
    if (startExtension > 0) {
      return filename.substring(startExtension + 1);
    }
    return "";
  }
1002900
private String readFile(File file) {
    BufferedReader reader = null;
    try {
      reader = new BufferedReader(new FileReader(file));
      String line = null;
      StringBuilder sb = new StringBuilder();
      String separator = System.getProperty("line.separator");
      while ((line = reader.readLine()) != null) {
        sb.append(line).append(separator);
      }

      return sb.toString();
    } catch (FileNotFoundException e) {
      throw new RuntimeException(
        "We already made sure the extra args file exists",
        e
      );
    } catch (IOException e) {
      throw new RuntimeException(
        "Error while reading from extra args file",
        e
      );
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException e) {
          SelendroidLogger.error("Failed to close reader for args file", e);
        }
      }
    }
  }
1206847
public static String getFileMD5String(File file) throws IOException {
        MessageDigest messageDigest = getMessageDigest(MD5);
        return getFileHashString(file, messageDigest);
    }
425399
private static String getFilePath(String file) {
        logger.entering(file);
        String filePath = null;
        URL fileURL = GuiMapReaderFactory.class.getClassLoader().getResource(file);
        if (fileURL != null) {
            filePath = fileURL.getPath();
        }
        logger.exiting(filePath);
        return filePath;
    }
63376
public JavaFileObject asJavaFileObject(File file) {
        JavacFileManager fm = (JavacFileManager)context.get(JavaFileManager.class);
        return fm.getRegularFile(file);
    }
710145
function(file) {
			var id = typeof(file) === 'string' ? file : file.id;

			for (var i = files.length - 1; i >= 0; i--) {
				if (files[i].id === id) {
					return this.splice(i, 1)[0];
				}
			}
		}
142661
private T loadFileValue(final File file)
	{
		final boolean reload;

		// First time / first time with this file
		if (cached == null || lastFile == null || lastFileModified == null || !lastFile.equals(file))
		{
			lastFile = file;
			lastFileModified = file.lastModified();
			reload = true;
		}
		else // Same file, so check timestamp to decide on reload
		{
			final long modified = file.lastModified();

			reload = modified > lastFileModified;

			if (reload)
				lastFileModified = modified;
		}

		if (reload)
		{
			cached = null; // Prevent the old value from being used

			setCached(clazz.cast(factory.getInstance(clazz).deserialise(file)));
		}

		return cached;
	}
934406
public String getExtension(final File file) {
		if (file != null) {
			final String fileName = file.getName();
			final int i = fileName.lastIndexOf('.');
			if (i > 0 && i < fileName.length() - 1) {
				return fileName.substring(i + 1).toLowerCase(Locale.getDefault());
			}
		}
		return null;
	}
149911
public static FileInfo parseFileName(File file)
    {
        // Owned filenames have the form:
        //    dbname/CURRENT
        //    dbname/LOCK
        //    dbname/LOG
        //    dbname/LOG.old
        //    dbname/MANIFEST-[0-9]+
        //    dbname/[0-9]+.(log|sst|dbtmp)
        String fileName = file.getName();
        if ("CURRENT".equals(fileName)) {
            return new FileInfo(FileType.CURRENT);
        }
        else if ("LOCK".equals(fileName)) {
            return new FileInfo(FileType.DB_LOCK);
        }
        else if ("LOG".equals(fileName)) {
            return new FileInfo(FileType.INFO_LOG);
        }
        else if ("LOG.old".equals(fileName)) {
            return new FileInfo(FileType.INFO_LOG);
        }
        else if (fileName.startsWith("MANIFEST-")) {
            long fileNumber = Long.parseLong(removePrefix(fileName, "MANIFEST-"));
            return new FileInfo(FileType.DESCRIPTOR, fileNumber);
        }
        else if (fileName.endsWith(".log")) {
            long fileNumber = Long.parseLong(removeSuffix(fileName, ".log"));
            return new FileInfo(FileType.LOG, fileNumber);
        }
        else if (fileName.endsWith(".sst")) {
            long fileNumber = Long.parseLong(removeSuffix(fileName, ".sst"));
            return new FileInfo(FileType.TABLE, fileNumber);
        }
        else if (fileName.endsWith(".dbtmp")) {
            long fileNumber = Long.parseLong(removeSuffix(fileName, ".dbtmp"));
            return new FileInfo(FileType.TEMP, fileNumber);
        }
        return null;
    }
594860
protected static String extractFileExtension(String fileName) {
		checkNotNull(fileName);
		int lastPeriodIndex = fileName.lastIndexOf('.');
		if (lastPeriodIndex < 0){
			return null;
		} else {
			return fileName.substring(lastPeriodIndex + 1);
		}
	}
39376
protected String getFileName(String fileName) {
        int index = fileName.lastIndexOf('.');
        return (index == -1) ? fileName : fileName.substring(0, index);
    }