List of usage examples for java.lang Long valueOf
public static Long valueOf(String s, int radix) throws NumberFormatException
From source file:Main.java
public static void main(String[] args) { String str = "123456789098765"; System.out.println("Value = " + Long.valueOf(str, 10)); }
From source file:Main.java
public static <RET> RET fromBase36(String basecode) { Long result = Long.valueOf(basecode, 36); long maxInt = new Long(Integer.MAX_VALUE); if (result > maxInt) { return ((RET) result); } else {//from w w w . j a v a 2s. co m return ((RET) (Integer) result.intValue()); } }
From source file:Main.java
public static int toInteger(byte[] source, int index) { StringBuilder valueStr = new StringBuilder(""); for (int i = 0; i < 4; i++) { valueStr.append(chars[(byte) ((source[index * 4 + i] & 0xF0) >> 4)]); valueStr.append(chars[(byte) (source[index * 4 + i] & 0x0F)]); }/* w w w.j ava2 s . c o m*/ return Long.valueOf(valueStr.toString(), 16).intValue(); }
From source file:com.blockwithme.longdb.tools.Utils.java
/** Attempts to read file with name - 'OriginalFileName'.crc32 if present : * Assumes that the content inside 'OriginalFileName'.crc32 file is equal to * the CRC32 value of the Original file. Calculates CRC32 value of the * current file and Compares it with the original value. In case if the * .crc32 file is not found, or the file size is not 8 bytes this method * returns false, If the file is found but the values don't match this * method throws a RuntimeExcepiton./*from w w w.ja va2 s .c om*/ * * @param theFile * the file * @param isCompressed * true if compressed * @return true, if checksum successful * @throws Exception */ // TODO: When do we need to differentiate the "no crc file" and // "bad crc" cases? Is it not a failure, one way or another? public static boolean checkSum(final File theFile, final boolean isCompressed) throws Exception { final File crcFile = new File(theFile.getAbsolutePath() + ".crc32"); if (!crcFile.exists() || crcFile.length() != INT_BYTES * 2) { return false; } final String crcCode = FileUtils.readFileToString(crcFile); final long expectedCRC = Long.valueOf(crcCode, 16); // $codepro.audit.disable // handleNumericParsingErrors if (getCRC32(theFile, isCompressed) != expectedCRC) throw new RuntimeException("CRC-32 validation failed for file:" + theFile.getAbsolutePath()); return true; }