ios吧图片专程nsdate,并把它放到了http头里,我是写java的,不知到该怎么接收。之前没做过,百度了很多,现在好乱啊,哪位好心人指点一下,谢谢!
1条回答 默认 最新
- 普通网友 2015-12-07 07:28关注
public boolean storeImage(File file){
try{
// 打开文件
FileInputStream fin = new FileInputStream(file);
// 建一个缓冲保存数据
ByteBuffer nbf = ByteBuffer.allocate((int) file.length());
byte[] array = new byte[1024];
int offset = 0, length = 0;
// 读存数据
while((length = fin.read(array)) > 0){
if(length != 1024) nbf.put(array,0,length);
else nbf.put(array);
offset += length;
}
// 关闭文件
fin.close();
// 新建一个数组保存要写的内容
byte[] content = nbf.array();
String sql = "insert into images (bin_data) values (?) ";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setBytes(1,content);
pstmt.execute();
pstmt.close();
}catch(Exception e){
e.printStackTrace();
return false;
}
return true;
}解决 无用评论 打赏 举报
悬赏问题
- ¥15 不同尺寸货物如何寻找合适的包装箱型谱
- ¥15 求解 yolo算法问题
- ¥15 虚拟机打包apk出现错误
- ¥15 用visual studi code完成html页面
- ¥15 聚类分析或者python进行数据分析
- ¥15 三菱伺服电机按启动按钮有使能但不动作
- ¥15 js,页面2返回页面1时定位进入的设备
- ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
- ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
- ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝