Java Code Examples for net.bither.bitherj.utils.Utils#readFile()

The following examples show how to use net.bither.bitherj.utils.Utils#readFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackupUtil.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private static ECKey getEckeyFormBackupHot(String address, CharSequence password) {
    File file = FileUtil.getBackupFile();
    String str = Utils.readFile(file);
    if (str.contains(address)) {
        String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
        for (String backupStr : backupStrArray) {
            if (backupStr.contains(address)) {
                String[] strArray = QRCodeUtil.splitString(backupStr);
                if (strArray.length > 3) {
                    String keyString = backupStr.substring(strArray[0]
                            .length() + 1);
                    return PrivateKeyUtil.getECKeyFromSingleString(
                            keyString, password);
                }
            }
        }
    }
    return null;
}
 
Example 2
Source File: AddErrorMsgRunnable.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    obtainMessage(HandlerMessage.MSG_PREPARE);
    try {
        File errorFile = new File(UEHandler.getErrorLogFile(),"error.log");
        if (errorFile.exists()) {
            String errorMsg = Utils.readFile(errorFile);
            if (!Utils.isEmpty(errorMsg)) {
                BitherErrorApi addFeedbackApi = new BitherErrorApi(errorMsg);
                addFeedbackApi.handleHttpPost();
            }
            errorFile.delete();
            obtainMessage(HandlerMessage.MSG_SUCCESS);
        }

    } catch (Exception e) {
        e.printStackTrace();
        obtainMessage(HandlerMessage.MSG_FAILURE_NETWORK);
    }

}
 
Example 3
Source File: BackupUtil.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private static ECKey getEckeyFormBackupHot(String address, CharSequence password) {
    File file = FileUtil.getBackupKeyOfHot();
    String str = Utils.readFile(file);
    if (str.contains(address)) {
        String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
        for (String backupStr : backupStrArray) {
            if (backupStr.contains(address)) {
                String[] strArray = QRCodeUtil.splitString(backupStr);
                if (strArray.length > 3) {
                    String keyString = backupStr.substring(strArray[0]
                            .length() + 1);
                    return PrivateKeyUtil.getECKeyFromSingleString(
                            keyString, password);
                }
            }
        }
    }
    return null;
}
 
Example 4
Source File: BackupUtil.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private static ECKey getEckeyFormBackupHot(String address, CharSequence password) {
    File file = FileUtil.getBackupFile();
    String str = Utils.readFile(file);
    if (str.contains(address)) {
        String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
        for (String backupStr : backupStrArray) {
            if (backupStr.contains(address)) {
                String[] strArray = QRCodeUtil.splitString(backupStr);
                if (strArray.length > 3) {
                    String keyString = backupStr.substring(strArray[0]
                            .length() + 1);
                    return PrivateKeyUtil.getECKeyFromSingleString(
                            keyString, password);
                }
            }
        }
    }
    return null;
}
 
Example 5
Source File: BackupUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private static ECKey getEckeyFormBackupCold(String address, CharSequence password) {

        try {
            File[] files = FileUtil.getBackupDir().listFiles();
            if (files == null) {
                return null;
            }
            files = FileUtil.orderByDateDesc(files);
            for (int i = files.length - 1;
                 i >= 0;
                 i++) {
                File file = files[i];
                String str = Utils.readFile(file);
                if (str.contains(address)) {
                    String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
                    for (String backupStr : backupStrArray) {
                        if (backupStr.contains(address)) {
                            String[] strArray = QRCodeUtil.splitString(backupStr);
                            if (strArray.length > 3) {
                                String keyString = backupStr
                                        .substring(strArray[0].length() + 1);
                                return PrivateKeyUtil.getECKeyFromSingleString(
                                        keyString, password);
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }
 
Example 6
Source File: BackupUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static String[] getBackupKeyStrList(File file) {
    String keyStrs = Utils.readFile(file);
    String[] result = null;
    if (!Utils.isEmpty(keyStrs)) {
        result = keyStrs.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
    }
    return result;
}
 
Example 7
Source File: ExchangeUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static AbstractMap<Currency, Double> getCurrenciesRate() {
    if (mCurrenciesRate == null) {
        File file = FileUtil.getCurrenciesRateFile();
        String rateString = Utils.readFile(file);
        try {
            JSONObject json = new JSONObject(rateString);
            mCurrenciesRate = parseCurrenciesRate(json);
        } catch (JSONException ex) {
            mCurrenciesRate = null;
        }
    }
    return mCurrenciesRate;
}
 
Example 8
Source File: BackupUtil.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private static ECKey getEckeyFormBackupCold(String address, CharSequence password) {
    if (!FileUtil.existSdCardMounted()) {
        return null;
    }
    try {
        File[] files = FileUtil.getBackupSdCardDir().listFiles();
        if (files == null) {
            return null;
        }
        files = FileUtil.orderByDateDesc(files);
        for (int i = files.length - 1;
             i >= 0;
             i++) {
            File file = files[i];
            String str = Utils.readFile(file);
            if (str.contains(address)) {
                String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
                for (String backupStr : backupStrArray) {
                    if (backupStr.contains(address)) {
                        String[] strArray = QRCodeUtil.splitString(backupStr);
                        if (strArray.length > 3) {
                            String keyString = backupStr
                                    .substring(strArray[0].length() + 1);
                            return PrivateKeyUtil.getECKeyFromSingleString(
                                    keyString, password);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;

}
 
Example 9
Source File: BackupUtil.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public static String[] getBackupKeyStrList(File file) {
    String keyStrs = Utils.readFile(file);
    String[] result = null;
    if (!Utils.isEmpty(keyStrs)) {
        result = keyStrs.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
    }
    return result;
}
 
Example 10
Source File: ExchangeUtil.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public static AbstractMap<Currency, Double> getCurrenciesRate() {
    if (mCurrenciesRate == null) {
        File file = FileUtil.getCurrenciesRateFile();
        String rateString = Utils.readFile(file);
        try {
            if (!Utils.isEmpty(rateString)) {
                JSONObject json = new JSONObject(rateString);
                mCurrenciesRate = parseCurrenciesRate(json);
            }
        } catch (JSONException ex) {
            mCurrenciesRate = null;
        }
    }
    return mCurrenciesRate;
}
 
Example 11
Source File: BackupUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private static ECKey getEckeyFormBackupCold(String address, CharSequence password) {

        try {
            File[] files = FileUtil.getBackupDir().listFiles();
            if (files == null) {
                return null;
            }
            files = FileUtil.orderByDateDesc(files);
            for (int i = files.length - 1;
                 i >= 0;
                 i++) {
                File file = files[i];
                String str = Utils.readFile(file);
                if (str.contains(address)) {
                    String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
                    for (String backupStr : backupStrArray) {
                        if (backupStr.contains(address)) {
                            String[] strArray = QRCodeUtil.splitString(backupStr);
                            if (strArray.length > 3) {
                                String keyString = backupStr
                                        .substring(strArray[0].length() + 1);
                                return PrivateKeyUtil.getECKeyFromSingleString(
                                        keyString, password);
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }
 
Example 12
Source File: BackupUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static String[] getBackupKeyStrList(File file) {
    String keyStrs = Utils.readFile(file);
    String[] result = null;
    if (!Utils.isEmpty(keyStrs)) {
        result = keyStrs.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
    }
    return result;
}
 
Example 13
Source File: ExchangeUtil.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public static AbstractMap<Currency, Double> getCurrenciesRate() {
    if (mCurrenciesRate == null) {
        File file = FileUtil.getCurrenciesRateFile();
        String rateString = Utils.readFile(file);
        try {
            JSONObject json = new JSONObject(rateString);
            mCurrenciesRate = parseCurrenciesRate(json);
        } catch (JSONException ex) {
            mCurrenciesRate = null;
        }
    }
    return mCurrenciesRate;
}