- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将视频文件存储到 SD 卡中我的应用程序文件夹中。目前我正在拍摄视频并且我有它的 URI。我怎样才能保存那个文件?请回复。提前致谢。
最佳答案
static void writeData(String fileurl, boolean append, String path,
String filename, Activity mContext) throws CustomException
{
URL myfileurl = null;
ByteArrayBuffer baf = null;
HttpURLConnection conn = null;
final int length;
try {
myfileurl = new URL(fileurl);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
conn = (HttpURLConnection) myfileurl
.openConnection();
conn.setDoInput(true);
conn.connect();
conn.setConnectTimeout(100000);
length = conn.getContentLength();
System.out.println("total length.." + length);
int interval = (int)length/100;
if (length > 0) {
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
baf = new ByteArrayBuffer(1000);
int current = 0;
while ((current = bis.read()) != -1) {
try {
baf.append((byte) current);
mBufferError=false;
} catch (Exception e){
// TODO: handle exception
mBufferError=true;
System.out.println("buffer Problem");
e.printStackTrace();
throw new CustomException("@@@ memory problem ", "Buffer Error");
}
}
}
} catch (IOException e) {
mBufferError=true;
System.out.println("HttpURLConnection");
e.printStackTrace();
}
try{
if(conn.getResponseCode()==200 && mBufferError==false)
{
path = path + "/" + filename;
boolean appendData = append;
FileOutputStream foutstream;
File file = new File(path);
boolean exist = false;
try {
if (appendData)
exist = file.exists();
else
exist = file.createNewFile();
} catch (IOException e) {
try {
System.out.println("@@@ existed file :" + path);
return;
} catch (Exception err) {
Log.e("SAX", err.toString());
}
}
if (!appendData && !exist) {
} else if (appendData && !exist) {
} else {
try {
foutstream = new FileOutputStream(file, appendData);
foutstream.write(baf.toByteArray());
foutstream.close();
} catch (Exception e) {
System.out.println("error in closing! " + e);
e.printStackTrace();
}
}
}
}catch (Exception e) {
// TODO: handle exception
throw new CustomException("@@@ I/O problem ", "I/O Error");
}
}
可以使用,其中 fileurl= 您的 Url 和 path= 本地存储路径
关于android - 将视频文件保存到 sd 卡文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6728651/
在我的代码中,我想以编程方式选择一些变量,并以硬编码方式选择和重命名其他一些变量。我知道我可以通过 setnames() 分两步实现这一点。 ,但我很好奇如何一步完成。 我想我很接近它通过 .SDco
(添加了可重现的示例。) 我对 rnorm 函数有点困惑。 我期待 mean(rnorm(100,mean=0,sd=1))为0;和 sd(rnorm(100,mean=0,sd=1))为 1。但给出
我想创建一个包含多个不同列的数据框,其中包含平均值,之后 sd 显示在括号中。举个例子: df % group_by(Species) %>% summarise_all(list(~ s
我很想知道 SD 卡是否提供类似于“SMART”信息的内容,例如硬盘和 SSD。 我有兴趣在 Raspberry PI 中检查 SD 卡的健康信息,以进行预防性更换。我的写入需求非常高,对设备的物理访
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
是否可以通过编程将 sd 卡中存在的文件夹复制到存在同一 sd 卡的另一个文件夹?? 如果是这样,该怎么做? 最佳答案 该示例的改进版本: // If targetLocation does not
Link :I worked on based on this Link 我添加了这一行来查找尺寸(内部和外部)尺寸, return availableExternalMemorySize/(1024
我正在开发一个应用程序,其中我需要从 sd 卡 中选择一个图像并在 ImageView 中显示它。现在我希望用户通过单击一个按钮来减小/增加其宽度,然后将其保存回 sd 卡。 我已经完成了图像挑选并在
在我的应用程序中,我使用以下 Intent 获得了 SD 卡写入权限。如果用户从系统文件资源管理器中选择 sd 卡文件夹,那么我就有 sd 卡写权限。 Intent intent = new Inte
给定一个data.table library(data.table) DT = data.table(x=rep(c("b","a","c"),each=3), v=c(1,1,1,2,2,1,1,2
我正在构建一个程序,该程序对 pin0 上的模拟电压进行 10 次测量,并将其打印到日志文件中。当我尝试确保文件为空时,我遇到了这个问题。我正在使用 SD.remove() 来删除以前的日志文件。当我
在 Android 的 API > 19 中是否有任何方法可以获取可移动 SD 卡的路径? 与外部 SD 卡一样,我们有 Environment.getExternalStorageDirectory
我使用以下方法检查手机是否包含 SD 卡,但如果 SD 卡不可用,问题总是返回 true,请帮助我。 Boolean isSDPresent = android.os.Environment.getE
这是我将 512 字节块写入 SD 卡的代码。代码工作正常,但是当我检查一切正常时(通过阅读 SD 的响应),我读到 0xFF . 该值应该类似于(来自 SD 引用手册): ‘010’—Data ac
我有两个线程在 epoll 上运行。一个线程尝试与服务器建立 TCP 连接,使用 EPOLL_CTL_ADD 选项将套接字添加到 epoll-fd。 另一个线程负责等待添加到 epoll-fd 的 S
我正在使用 eclipse 模拟器,我想以编程方式将一些 mp3 从 /sdcard/songs 复制到 /sdcard/backup,有什么办法吗?非常感谢任何帮助和代码 fragment !谢谢!
我正在使用 Docker Desktop for Mac 版本 2.1.0.4。我有一个 Docker 容器,它是一个 Ubuntu 18.04 Linux VM,里面有 Yocto Build 系统
好的,这个黑莓应用程序在第一次安装和运行时创建了一个数据库。它安装在 SD 卡上。 当我删除应用程序时 - 这个文件仍然存在,我在删除应用程序时找不到任何删除它的方法。 有什么建议么? 最佳答案 应用
我有一张 SD 卡(或 SDHC 卡)通过 SPI 模式连接到微 Controller 。我正在使用 Chan’s FAT图书馆。我将来自 8192 字节缓冲区的数据写入其中(由于 RAM 不足,缓冲
我想在删除该选择中的最小值和最大值后,计算数据框中每一行在该选择列上的标准差。这是一个例子: set.seed(1) dat dat X1 X2 X3 X4 X5 sd 1 27 5
我是一名优秀的程序员,十分优秀!