private boolean saveToPath(File file, Bitmap bitmap) { boolean isSuccess = true; try { if (file.exists()) return true; // bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] imageInByte = stream.toByteArray(); long length = imageInByte.length; com.netease.vendor.util.log.LogUtil.vendor("length=" + length); if (MIN_IMAGE_SIZE >= length) { stream.close(); return false; } FileOutputStream fos = new FileOutputStream(file); stream.writeTo(fos); fos.flush(); stream.close(); fos.close(); } catch (Exception e) { e.printStackTrace(); isSuccess = false; } return isSuccess; }
private void delFolder(String folderPath) { try { deleteAllFileInFolder(folderPath); // 删除完里面所有内容 String filePath = folderPath; filePath = filePath.toString(); File myFilePath = new File(filePath); myFilePath.delete(); // 删除空文件夹 } catch (Exception e) { com.netease.vendor.util.log.LogUtil.vendor("删除文件夹操作出错"); e.printStackTrace(); } }