安卓手机上弄了个ps2模拟器存档导入 怎么导入pc

android客户端把SD卡文件上传到服务器端并保存在PC硬盘文件夹中
在局域网内,实现从android客户端把手机SD卡上的文件上传到PC服务器端,并保存在PC硬盘的指定文件夹下。同时把PC端硬盘文件的目录和对文件的描述信息保存在中。
1、客户端关键代码:
(1)获得SD卡上的文件
* 获得文件路径和状态信息
private String getFiles() {
File path =
// 判断SD卡是否存在可用
if (Environment.getExternalStorageState().equals(
Environment.MEDIA_MOUNTED)) {
path = Environment.getExternalStorageDirectory();
File[] files = path.listFiles();
for (File file : files) {
// 把路径如入集合中
if (file.getPath() != null
&& (file.getPath()
.substring(file.getPath().lastIndexOf("/") + 1)
.equals("DATA_RECORD.pcm"))) {
return file.getPath();
Toast.makeText(ASRMainActivity.this, "SD卡不可用!", 300).show();
(2)实现文件上传的方法
private void fileUpLoad() {
srcPath=getFiles();
new AsyncTask() {
String end = "\r\n";
String twoHyphens = "--";
String boundary = "****************";
InputStreamReader isr =
FileInputS
DataOutputS
protected Void doInBackground(Void... params) {
String record_content=mSharedPreferences.getString("content","");
Log.i("测试",record_content);
// 首先指定服务器的路径URL
url = new URL(
"http://192.168.1.109:8080/MFCC/SpeechRecognizeAction?action_flag=upload&record_content="+record_content);
// 打开一个连接
con = (HttpURLConnection) url.openConnection();
// 设置一些属性
con.setDoInput(true);
con.setDoOutput(true);
con.setDefaultUseCaches(false);
con.setRequestMethod("POST");
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Charset", "UTF-8");
con.setRequestProperty("Content-Type",
"multipart/form-boundary=" + boundary);
con.setReadTimeout(3000);
// 创建一个新的数据输出流,将数据写入指定基础输出流
dos = new DataOutputStream(con.getOutputStream());
// 将字符串按字节顺序 写出 到基础输出流中
// dos.writeBytes("Content-Disposition: form- name=\"uploads\";filename=1.txt");
// dos.writeBytes("Content-Disposition: form-");
dos.writeBytes(twoHyphens + boundary + end);
dos.writeBytes("Content-Disposition: form- name=\"file\"; filename=\""
+ srcPath.substring(srcPath.lastIndexOf("/") + 1)
+ "\"" + end);
Log.i("tag",
"Content-Disposition: form- name=\"file\"; filename=\""
+ srcPath.substring(srcPath
.lastIndexOf("/") + 1) + "\"" + end);
dos.writeBytes(end);
// dos.writeBytes("1.txt");
// dos.writeBytes("Jonny-Resume.docx");
// 读取写到输出流中的数据
fis = new FileInputStream(srcPath);
byte[] buffer = new byte[8192]; // 8k
int count = 0;
count = fis.read(buffer);
Log.i("tag", count + "
********************");
while ((count = fis.read(buffer)) != -1) {
dos.write(buffer, 0, count);
Log.i("tag", "ok");
fis.close();
dos.writeBytes(end);
dos.writeBytes(twoHyphens + boundary + twoHyphens + end);
dos.flush();
// 反馈给客户端的信息
InputStream is = con.getInputStream();
isr = new InputStreamReader(is, "utf-8");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
protected void onPostExecute(Void result) {
String result2 =
StringBuffer stringBuffer =
BufferedReader br =
if (isr == null) {
br = new BufferedReader(isr);
stringBuffer = new StringBuffer();
while ((result2 = br.readLine()) != null) {
stringBuffer.append(result2);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (dos != null) {
dos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if (fis != null) {
fis.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if (stringBuffer != null)
Toast.makeText(ASRMainActivity.this,
new String(stringBuffer), Toast.LENGTH_LONG).show();
btn_uploadFile.setEnabled(true);
}.execute();
服务器端关键代码:
* 上传文件到PC,并把相关的文件信息写如数据库
* @param request
* @param response
private void uploadFile(HttpServletRequest request, HttpServletResponse response) {
String content = request.getParameter("record_content");
PrintWriter printWriter=
DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();// 实例化一个文件工厂
// 构建一个文件上传类
ServletFileUpload servletFileUpload = new ServletFileUpload(
diskFileItemFactory);// 生成一个处理文件上传的servlet对象
servletFileUpload.setFileSizeMax(3 * 1024 * 1024);
servletFileUpload.setSizeMax(6 * 1024 * 1024);// 上传文件总大小
// 分析请求,并得到上传文件的FileItem对象
printWriter=response.getWriter();
List items = servletFileUpload.parseRequest(request);
Iterator e = items.iterator();
while (e.hasNext()) {
FileItem item = e.next();
if (item.getName() != null && !item.getName().equals("")) {
File file = new File("E://rawSpeechRecordData//");
File newFile =
if (!file.exists()) {
file.mkdir();
if (file.isDirectory()) {
SimpleDateFormat format = new SimpleDateFormat(
"yyyyMMddHHmmss");
String date = format.format(new Date(System
.currentTimeMillis()));
newFile = new File(
"E://rawSpeechRecordData//rawdata" + date
item.write(newFile);
//数据存入数据库
System.out.println("**********************"
+ newFile.getPath());
mFileInfoDao.addFilePathInfos(newFile.getPath(), content);
printWriter.write("数据提交成功!");
System.out.println(file);
System.out
.println("Content-Disposition: form- name=\"file\"; filename=\"");
System.out.println("**********************");
if (file.isDirectory()) {
SimpleDateFormat format = new SimpleDateFormat(
"yyyyMMddHHmmss");
String date = format.format(new Date(System
.currentTimeMillis()));
newFile = new File(
"E://rawSpeechRecordData//rawdata" + date
item.write(newFile);
//数据存入数据库
mFileInfoDao.addFilePathInfos(newFile.getPath(), content);
printWriter.write("数据提交成功!");
System.out.println("**********************"
+ newFile.getPath());
System.out.println(file);
System.out
.println("Content-Disposition: form- name=\"file\"; filename=\"");
System.out.println("**********************");
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
(1)数据库操作接口定义
public interface FileInfoDao {
* 添加文件路径到数据库
* @param filePath 文件路径
* @param content录音的详细信息
public void addFilePathInfos(String filePath,String content);
* 删除一条录音的路径信息
* @param content 录音的详细信息
public void deleteAFilePathInfo(String content);
* 删除所有的录音文件路径
public void deleteAllFilePathInfos();
* 查询所有的文件路径
public List<Map> getAllFilePaths();
(2)数据库操作实现类
public class FileInfoDaoimpl implements FileInfoDao {
// 表示定义数据库的用户名
private final String USERNAME = "root";
// 定义数据库的密码
private final String PASSWORD = "admin";
// 定义数据库的驱动信息
private final static String DRIVER = "com.mysql.jdbc.Driver";
// 定义数据库连接
private static Connection mC
// 定义访问数据库的地址
private final String URL = "jdbc:mysql://192.168.1.109:3306/fileinfos";
// 定义sql语句的执行对象
private PreparedS
// 定义查询返回的结果集合
private ResultSet resultS
public FileInfoDaoimpl() {
// 加载驱动
Class.forName(DRIVER);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
public void addFilePathInfos(String filePath, String content) {
PreparedStatement preparedStatement =
// 获得数据库连接
mConnection = DriverManager.getConnection(URL, "root", "admin");
// 获得SQL语句执行对象
preparedStatement = mConnection
.prepareStatement("insert into filepaths(file_path,record_content) values(?,?)");
// 设置参数
preparedStatement.setString(1, filePath);
preparedStatement.setString(2, content);
// 执行SQL语句
preparedStatement.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (preparedStatement != null) {
preparedStatement.close();
preparedStatement =
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if (mConnection != null) {
mConnection.close();
mConnection =
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
public void deleteAFilePathInfo(String content) {
PreparedStatement preparedStatement=
//获得数据库连接
mConnection=DriverManager.getConnection(URL,"root","admin");
//获得SQL语句执行对象
preparedStatement=mConnection.prepareStatement("delete from filepaths where record_content=?");
//设置参数
preparedStatement.setString(1, content);
preparedStatement.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if(preparedStatement!=null){
preparedStatement.close();
preparedStatement=
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if(mConnection!=null){
mConnection.close();
mConnection=
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
public void deleteAllFilePathInfos() {
PreparedStatement preparedStatement=
mConnection=DriverManager.getConnection(URL, USERNAME,PASSWORD);
preparedStatement=mConnection.prepareStatement("delete from filepaths");
preparedStatement.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if(preparedStatement!=null){
preparedStatement.close();
preparedStatement=
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if(mConnection!=null){
mConnection.close();
mConnection=
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
public List<Map> getAllFilePaths() {
PreparedStatement preparedStatement=
List<Map> results=new ArrayList<Map>();
HashMap result=
mConnection=DriverManager.getConnection(URL, USERNAME, PASSWORD);
preparedStatement=mConnection.prepareStatement("select file_path,record_content from filepaths");
resultSet= preparedStatement.executeQuery();
while(resultSet.next()){
result=new HashMap();
result.put("filepath", resultSet.getString("file_path"));
result.put("record_content", resultSet.getString("record_content"));
results.add(result);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if(preparedStatement!=null){
preparedStatement.close();
preparedStatement=
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if(mConnection!=null){
mConnection.close();
mConnection=
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
(3)数据库操作对象的静态工厂方法(单例模式)
public class FilePathInfosDaoFactory {
private static FileInfoDao mFileInfoD
* 获得数据库操作单例对象
public static FileInfoDao getInstanse() {
if (mFileInfoDaoimpl == null) {
mFileInfoDaoimpl = new FileInfoDaoimpl();
return mFileInfoD
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'橙光游戏手机存档是否可以在电脑上同步,,若可以,该如何操作,苹果上有个游戏叫 lifeline (生命线),我想把他移植到PC上,以后再打算移植到安卓,大概是
来源:网络
关键字: 存档 同步
更新时间:
延伸:本文除了聚合《橙光游戏手机存档是否可以在电脑上同步,,若可以,该如何操作》,免费提供的有关存档 同步和苹果上有个游戏叫 lifeline (生命线),我想把他移植到PC上,以后再打算移植到安卓,大概是的内容之一,已有不少的网友认为此答案对自己有帮助!获取更多与《》相关的知识。
网友0的回答
楼主必定是程序员中的极品 !能将一个苹果程序移植到PC再到Android,而且还是一个人,是在下输了网友1的回答
/#bdzz网友2的回答
改内容……就是一个新的游戏了,过不过审还要看新游戏的剧情嘛= = 满意望采纳,谢谢~网友1的回答
电脑网络娱乐休闲行政地区心理分析医疗手机版 我的知道 搜索答案 橙光游戏制作里网友0的回答
电脑网络娱乐休闲行政地区心理分析医疗卫生专栏知道日报真相手机版 我网友1的回答
电脑网络娱乐休闲行政地区心理分析医疗手机版 我的知道 搜索答案 橙光游戏制作怎网友2的回答
电脑网络娱乐休闲行政地区心理分析医疗手机版 我的知道 橙光游戏之三妻四妾的全部网友1的回答
找回密码方法:选择“验证密保找回密码”,若没有设置或忘记了,就进行“申诉”。   两种情况操作步骤分网友0的回答
HP纯血荣耀攻略: 第一年:斯莱特林我还是中意斯莱特林试着安慰他帮他解围精纯 的魔力网友1的回答
最满意的回答
猜你感兴趣
回答问题赢iPhone 6最新公告:
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
>> 图片信息
&&网友评论:(只显示最新5条。评论内容只代表网友观点,与本站立场无关!)
&&&&没有任何评论
本站由南京师范大学视觉文化研究所主办 2005年获中国教育技术协会年会教育主题网站一等奖

我要回帖

更多关于 gta5pc存档怎么导入 的文章

 

随机推荐