Retrieves the timestamp from the name of the file.

@param file to retrieve timestamp from.
@return timestamp in millis or -1 if name's pattern does not correspond
to the one used for files in the repository.
356903
public long getLogFileTimestamp(File file) {
        if (file == null) {
            return -1L;
        }

        String name = file.getName();

        // Check name for extension
        if (name == null || name.length() == 0 || !name.endsWith(EXTENSION)) {
            return -1L;
        }

        try {
            return Long.parseLong(name.substring(0, name.indexOf(EXTENSION)));
        } catch (NumberFormatException ex) {
            return -1L;
        }
    }
888668
public String readFileContent(File file) {
        StringBuilder fileContentBuilder = new StringBuilder();
        if (file.exists()) {
            String stringLine;
            try {
                FileReader fileReader = new FileReader(file);
                BufferedReader bufferedReader = new BufferedReader(fileReader);
                while ((stringLine = bufferedReader.readLine()) != null) {
                    fileContentBuilder.append(stringLine + "\n");
                }
                bufferedReader.close();
                fileReader.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return fileContentBuilder.toString();
    }
50217
public String calculateVersionFrom(@NotNull File file){
        Objects.requireNonNull(file, "file argument cannot be null");
        //optimise by store hash against file modified time, on subsequent calls, check file modified time first to determine file and time is present and return previous data.
        final long lastModified = file.lastModified();
        final String key = file.getAbsolutePath() + lastModified;
        final String storedHashValue = fixedSizeCache.get(key);
        if(!StringUtils.isEmpty(storedHashValue)){
            return storedHashValue;
        }
        final String digestHex;
        try {
            digestHex = getHashFromBytes(Files.readAllBytes(file.toPath()));
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        fixedSizeCache.put(key, digestHex);
        return digestHex;
    }
1345293
public static String getExtension(final String file) {
        final int index = file.indexOf(SHARP);

        if (file.startsWith(SHARP)) {
            return null;
        } else if (index != -1) {
            final String fileName = file.substring(0, index);
            final int fileExtIndex = fileName.lastIndexOf(DOT);
            return fileExtIndex != -1 ? fileName.substring(fileExtIndex + 1) : null;
        } else {
            final int fileExtIndex = file.lastIndexOf(DOT);
            return fileExtIndex != -1 ? file.substring(fileExtIndex + 1) : null;
        }
    }
715571
public static long readLongFromFile(File file) throws IOException {
    try (FileInputStream fis = new FileInputStream(file);
         BufferedReader br = new BufferedReader(
           new InputStreamReader(fis, Charset.forName("UTF-8")))) {
      long value = Long.parseLong(br.readLine());
      return value;
    }
  }
350009
public JavaFileObject useSource(JavaFileObject file) {
        JavaFileObject prev = (source == null ? null : source.getFile());
        source = getSource(file);
        return prev;
    }
734033
@Nonnull
    public static String getDigestOf(@Nonnull File file) throws IOException {
        // Note: getDigestOf() closes the input stream.
        return getDigestOf(Files.newInputStream(fileToPath(file)));
    }
1102705
def timestamp_filename(basename, ext=None):
    
    dt = datetime.now().strftime('%Y%m%d-%H%M%S-%f')
    if ext:
        return '%s-%s.%s' % (basename, dt, ext)
    return '%s-%s' % (basename, dt)
1312438
public static String getBasename(final File file) {
    final String path = file.getPath();
    // Remove the extension
    String basename = file.getName();
    final int pos = basename.lastIndexOf('.');
    if (pos != -1) {
      basename = basename.substring(0, pos);
    }
    return basename;
  }
1041206
private String getSourceSetNameFromFile(File file) {
    Path absolutePath = Paths.get(file.getAbsolutePath());
    Path basePath = Paths.get(task.getProject().file("src").getAbsolutePath());

    return basePath.relativize(absolutePath).toString().split(Matcher.quoteReplacement(File.separator))[0];
  }
607160
public static Document getDocument(File file) {
        InputStream inputStream = null;

        try {
            inputStream = new FileInputStream(file);
        } catch (FileNotFoundException ex) {
            throw new MjdbcRuntimeException(ex);
        }

        return XmlRepositoryFactory.getDocument(inputStream);
    }
484136
public static String getSuffix(File file) {

        String filename = file.getName();
        int index = filename.lastIndexOf(".");
        if (index != -1) {
            return filename.substring(index + 1);
        }

        return filename;
    }
845513
public static String readFile(InputStream file) {
        try (BufferedInputStream stream = new BufferedInputStream(file)) {
            byte[] buff = new byte[1024];
            StringBuilder builder = new StringBuilder();
            int read;
            while ((read = stream.read(buff)) != -1) {
                builder.append(new String(buff, 0, read, StandardCharsets.UTF_8));
            }
            return builder.toString();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
251414
public java.sql.Time getTime(String column) {
		return (java.sql.Time)getColumns().get(column);
	}
970724
static String getVersionForFile(final File file)  {
        try {
            final PluginMeta pluginMeta = loadMeta(file);
            return pluginMeta.getVersion();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
569501
public java.sql.Timestamp getTimestamp(String column) {
		return (java.sql.Timestamp)getColumns().get(column);
	}
275696
private static String getFileExtension(Resource file) {
	String name = file.getName();
	int index = name.lastIndexOf('.');
	if (index == -1) return null;
	return name.substring(index + 1).trim();
    }