|
|
|
@ -9,7 +9,7 @@ import java.io.FileOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 文件工具类 |
|
|
|
|
* file tool |
|
|
|
|
* Created by frank on 2018/5/9. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
@ -37,18 +37,18 @@ public class FileUtil { |
|
|
|
|
private final static String TYPE_MOV = "mov"; |
|
|
|
|
private final static String TYPE_MPG = "mpg"; |
|
|
|
|
|
|
|
|
|
public static boolean concatFile(String srcFilePath, String appendFilePath, String concatFilePath){ |
|
|
|
|
if(TextUtils.isEmpty(srcFilePath) |
|
|
|
|
public static boolean concatFile(String srcFilePath, String appendFilePath, String concatFilePath) { |
|
|
|
|
if (TextUtils.isEmpty(srcFilePath) |
|
|
|
|
|| TextUtils.isEmpty(appendFilePath) |
|
|
|
|
|| TextUtils.isEmpty(concatFilePath)){ |
|
|
|
|
|| TextUtils.isEmpty(concatFilePath)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
File srcFile = new File(srcFilePath); |
|
|
|
|
if(!srcFile.exists()){ |
|
|
|
|
if (!srcFile.exists()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
File appendFile = new File(appendFilePath); |
|
|
|
|
if(!appendFile.exists()){ |
|
|
|
|
if (!appendFile.exists()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
FileOutputStream outputStream = null; |
|
|
|
@ -59,25 +59,25 @@ public class FileUtil { |
|
|
|
|
outputStream = new FileOutputStream(new File(concatFilePath)); |
|
|
|
|
byte[] data = new byte[1024]; |
|
|
|
|
int len; |
|
|
|
|
while ((len = inputStream1.read(data)) > 0){ |
|
|
|
|
while ((len = inputStream1.read(data)) > 0) { |
|
|
|
|
outputStream.write(data, 0, len); |
|
|
|
|
} |
|
|
|
|
outputStream.flush(); |
|
|
|
|
while ((len = inputStream2.read(data)) > 0){ |
|
|
|
|
while ((len = inputStream2.read(data)) > 0) { |
|
|
|
|
outputStream.write(data, 0, len); |
|
|
|
|
} |
|
|
|
|
outputStream.flush(); |
|
|
|
|
} catch (IOException e){ |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
}finally { |
|
|
|
|
} finally { |
|
|
|
|
try { |
|
|
|
|
if(inputStream1 != null){ |
|
|
|
|
if (inputStream1 != null) { |
|
|
|
|
inputStream1.close(); |
|
|
|
|
} |
|
|
|
|
if(inputStream2 != null){ |
|
|
|
|
if (inputStream2 != null) { |
|
|
|
|
inputStream2.close(); |
|
|
|
|
} |
|
|
|
|
if(outputStream != null){ |
|
|
|
|
if (outputStream != null) { |
|
|
|
|
outputStream.close(); |
|
|
|
|
} |
|
|
|
|
} catch (IOException e) { |
|
|
|
@ -88,16 +88,17 @@ public class FileUtil { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断文件是否存在 |
|
|
|
|
* @param path 文件路径 |
|
|
|
|
* @return 文件是否存在 |
|
|
|
|
* check the file exist or not |
|
|
|
|
* |
|
|
|
|
* @param path the path of file |
|
|
|
|
* @return result of exist or not |
|
|
|
|
*/ |
|
|
|
|
public static boolean checkFileExist(String path){ |
|
|
|
|
public static boolean checkFileExist(String path) { |
|
|
|
|
if (TextUtils.isEmpty(path)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
File file = new File(path); |
|
|
|
|
if(!file.exists()){ |
|
|
|
|
if (!file.exists()) { |
|
|
|
|
Log.e("FileUtil", path + " is not exist!"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -178,7 +179,7 @@ public class FileUtil { |
|
|
|
|
} |
|
|
|
|
outputStream = new FileOutputStream(listFile); |
|
|
|
|
StringBuilder fileBuilder = new StringBuilder(); |
|
|
|
|
for (String file:fileArray) { |
|
|
|
|
for (String file : fileArray) { |
|
|
|
|
fileBuilder |
|
|
|
|
.append("file") |
|
|
|
|
.append(" ") |
|
|
|
|