English 中文(简体)
• 如何将图像数据作为基础64加以记录?
原标题:how to write image data to a text file as a base 64 string?

试图将图像数据写到文本档案中,作为第64号基数,如果该数据库含有大量信息,但如果含有相当一部分信息,则该数据便坠毁了该应用程序,称其除记忆如下:

package com.search.visual;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Environment;
import android.util.Base64;
import android.util.Log;
import android.widget.Toast;

public class SavePhotoTask extends AsyncTask<byte[], String, String>{
    String name;
    byte[] num;
    @Override
    protected String doInBackground(byte[]... params) {
        // TODO Auto-generated method stub
    File photo = new File(Environment.getExternalStorageDirectory(),".vis/image.xml");

    name = Base64.encodeToString(params[0], 0);



    //return base64String;
    if (photo.exists()){
        photo.delete();
    }
    try{



        FileWriter fi = new FileWriter(photo.getPath());
        fi.write("<Image>
	<Data>");
        fi.write(name);

        fi.write("</Data>
</Image>");
        fi.close();


    }catch (IOException e) {
        // TODO: handle exception
        Log.e("pictureDemo","exception", e);
    }


    return (null);
}

    }

究竟是做错事,还是有更好的办法这样做?

事先感谢你

最佳回答

象你这样的声音只是从援助团中脱出来。 出现这种情况的一个原因是,你重新掌握了整个原始形象和整个基64的图像,甚至只是简略。 a. 采用变式,在休息时间填写数据:

encodeToString(byte[] input, int offset, int len, int flags)

time time writing

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签