| | |
| | |
|
| | | public static File writeToFile(String fileName, byte[] fileBytes) {
|
| | | try {
|
| | | return writeToFile(fileName, fileBytes, 0, fileBytes.length);
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | public static File writeToFile(String fileName, byte[] fileBytes, int offset, int size) {
|
| | | try {
|
| | | if (fileBytes == null) {
|
| | | fileBytes = new byte[]{};
|
| | | }
|
| | |
| | | }
|
| | | file.createNewFile();
|
| | | BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(dir, fileName)));
|
| | | bos.write(fileBytes);
|
| | | bos.write(fileBytes, offset, size);
|
| | | bos.flush();
|
| | | bos.close();
|
| | | return new File(dir, fileName);
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static File getFile(String shortFileName) {
|
| | | String dir = MainActivity.getInstance().getFilesDir().getAbsolutePath();
|
| | | return new File(dir, shortFileName);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | }
|
| | |
|
| | |
|
| | | public static void deleteFile(String fileName) {
|
| | | try {
|
| | | String dir = MainActivity.getInstance().getFilesDir().getAbsolutePath();
|
| | |
|
| | | File file = new File(dir, fileName);
|
| | | if (file.exists()) {
|
| | | file.delete();
|
| | | }
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|