Issue#22 updated SibaUtils
This commit is contained in:
parent
6f507c7d27
commit
2925a8090b
|
@ -43,19 +43,19 @@ public class SibaUtils
|
||||||
*
|
*
|
||||||
* This method Generate the file with MD5.
|
* This method Generate the file with MD5.
|
||||||
*
|
*
|
||||||
* @param inputDirectory
|
* @param inputFile
|
||||||
* @param target
|
* @param target
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws NoSuchAlgorithmException
|
* @throws NoSuchAlgorithmException
|
||||||
*/
|
*/
|
||||||
public static File createMD5File(final File inputDirectory, final String target)
|
public static File createMD5File(final File inputFile, final String target)
|
||||||
throws IOException, NoSuchAlgorithmException
|
throws IOException, NoSuchAlgorithmException
|
||||||
{
|
{
|
||||||
File result;
|
File result;
|
||||||
|
|
||||||
String md5 = SibaUtils.md5(inputDirectory);
|
String md5 = SibaUtils.md5(inputFile);
|
||||||
String fileName = inputDirectory.getName();
|
String fileName = inputFile.getName();
|
||||||
result = createMD5File(md5, fileName, target);
|
result = createMD5File(md5, fileName, target);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -65,8 +65,7 @@ public class SibaUtils
|
||||||
public static File createMD5File(final String md5, final String fileName, final String target) throws IOException
|
public static File createMD5File(final String md5, final String fileName, final String target) throws IOException
|
||||||
{
|
{
|
||||||
File result;
|
File result;
|
||||||
FileWriter fileWriter;
|
FileWriter fileWriter = null;
|
||||||
fileWriter = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = new File(target);
|
result = new File(target);
|
||||||
|
@ -95,17 +94,16 @@ public class SibaUtils
|
||||||
public static String loadMD5Sum(final File choosenFile) throws IOException
|
public static String loadMD5Sum(final File choosenFile) throws IOException
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
FileReader fileReader;
|
FileReader in = null;
|
||||||
fileReader = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (choosenFile.exists() && (choosenFile.length() > 32))
|
if (choosenFile.exists() && (choosenFile.length() > 32))
|
||||||
{
|
{
|
||||||
fileReader = new FileReader(choosenFile);
|
in = new FileReader(choosenFile);
|
||||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
BufferedReader bufferedReader = new BufferedReader(in);
|
||||||
String line = bufferedReader.readLine();
|
String line = bufferedReader.readLine();
|
||||||
result = line.substring(0, 32);
|
result = line.substring(0, 32);
|
||||||
fileReader.close();
|
in.close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -114,7 +112,7 @@ public class SibaUtils
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtils.closeQuietly(fileReader);
|
IOUtils.closeQuietly(in);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
@ -181,19 +179,18 @@ public class SibaUtils
|
||||||
public static File readFileNameToCheck(final File choosenFile) throws IOException
|
public static File readFileNameToCheck(final File choosenFile) throws IOException
|
||||||
{
|
{
|
||||||
File result;
|
File result;
|
||||||
FileReader fileReader;
|
FileReader in = null;
|
||||||
fileReader = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// result = null;
|
// result = null;
|
||||||
if (choosenFile.exists() && (choosenFile.length() > 32))
|
if (choosenFile.exists() && (choosenFile.length() > 32))
|
||||||
{
|
{
|
||||||
fileReader = new FileReader(choosenFile);
|
in = new FileReader(choosenFile);
|
||||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
BufferedReader bufferedReader = new BufferedReader(in);
|
||||||
String line = bufferedReader.readLine();
|
String line = bufferedReader.readLine();
|
||||||
String fileNameToString = new String();
|
String fileNameToString = new String();
|
||||||
fileNameToString = line.substring(33);
|
fileNameToString = line.substring(33);
|
||||||
fileReader.close();
|
in.close();
|
||||||
if (choosenFile.isAbsolute())
|
if (choosenFile.isAbsolute())
|
||||||
{
|
{
|
||||||
result = new File(choosenFile.getParent() + "/" + fileNameToString);
|
result = new File(choosenFile.getParent() + "/" + fileNameToString);
|
||||||
|
@ -212,7 +209,7 @@ public class SibaUtils
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtils.closeQuietly(fileReader);
|
IOUtils.closeQuietly(in);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user