rename choosenFile
This commit is contained in:
parent
b1a83a95f6
commit
63a6688fc8
|
@ -134,20 +134,20 @@ public final class SibaManager
|
||||||
/**
|
/**
|
||||||
* This method is used to check the file.
|
* This method is used to check the file.
|
||||||
*
|
*
|
||||||
* @param choosenFile
|
* @param md5FileToCheck
|
||||||
* the file to check
|
* the file to check
|
||||||
* @return the result of check
|
* @return the result of check
|
||||||
* @throws SibaException
|
* @throws SibaException
|
||||||
* specific exception
|
* specific exception
|
||||||
*/
|
*/
|
||||||
public static boolean check(final File choosenFile) throws SibaException
|
public static boolean check(final File md5FileToCheck) throws SibaException
|
||||||
{
|
{
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String md5String = SibaUtils.loadMD5Sum(choosenFile);
|
String md5String = SibaUtils.loadMD5Sum(md5FileToCheck);
|
||||||
File fileToCheck1 = SibaUtils.readFileNameToCheck(choosenFile);
|
File fileToCheck1 = SibaUtils.readFileNameToCheck(md5FileToCheck);
|
||||||
if (StringUtils.equals(md5String, SibaUtils.md5(fileToCheck1)))
|
if (StringUtils.equals(md5String, SibaUtils.md5(fileToCheck1)))
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
|
|
|
@ -115,22 +115,22 @@ public final class SibaUtils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param choosenFile
|
* @param md5File
|
||||||
* the file to check
|
* the file to check
|
||||||
* @return The MD5sum
|
* @return The MD5sum
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* IOException
|
* IOException
|
||||||
*/
|
*/
|
||||||
public static String loadMD5Sum(final File choosenFile) throws IOException
|
public static String loadMD5Sum(final File md5File) throws IOException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
FileReader in = null;
|
FileReader in = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (choosenFile.exists() && (choosenFile.length() > 32))
|
if (md5File.exists() && (md5File.length() > 32))
|
||||||
{
|
{
|
||||||
in = new FileReader(choosenFile);
|
in = new FileReader(md5File);
|
||||||
BufferedReader bufferedReader = new BufferedReader(in);
|
BufferedReader bufferedReader = new BufferedReader(in);
|
||||||
String line = bufferedReader.readLine();
|
String line = bufferedReader.readLine();
|
||||||
result = line.substring(0, 32);
|
result = line.substring(0, 32);
|
||||||
|
@ -208,30 +208,30 @@ public final class SibaUtils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param choosenFile
|
* @param md5File
|
||||||
* The MD5file
|
* The MD5file
|
||||||
* @return the file to check
|
* @return the file to check
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* IOException
|
* IOException
|
||||||
*/
|
*/
|
||||||
public static File readFileNameToCheck(final File choosenFile) throws IOException
|
public static File readFileNameToCheck(final File md5File) throws IOException
|
||||||
{
|
{
|
||||||
File result;
|
File result;
|
||||||
|
|
||||||
FileReader in = null;
|
FileReader in = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (choosenFile.exists() && (choosenFile.length() > 32))
|
if (md5File.exists() && (md5File.length() > 32))
|
||||||
{
|
{
|
||||||
in = new FileReader(choosenFile);
|
in = new FileReader(md5File);
|
||||||
BufferedReader bufferedReader = new BufferedReader(in);
|
BufferedReader bufferedReader = new BufferedReader(in);
|
||||||
String line = bufferedReader.readLine();
|
String line = bufferedReader.readLine();
|
||||||
String fileNameToString;
|
String fileNameToString;
|
||||||
fileNameToString = line.substring(33);
|
fileNameToString = line.substring(33);
|
||||||
in.close();
|
in.close();
|
||||||
if (choosenFile.isAbsolute())
|
if (md5File.isAbsolute())
|
||||||
{
|
{
|
||||||
result = new File(choosenFile.getParent(), fileNameToString);
|
result = new File(md5File.getParent(), fileNameToString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue