my write code
    public static void writeFBTagToCache(long crc64) {
        try {


            ArrayList<tagStruct> tags = mItem.getTags();

            if(tags == null || tags.size() <= 0) {
                Log.d(TAG, "tags is null + " + mItem.mGuid);
                return;
            }

            int size = tags.size();
            File tempFile = null;
            final String tempFilePath = FB_TAG_CACHE;
            String prefix = crc64 + "";
            tempFile = File.createTempFile(prefix, ".cache", new
File(tempFilePath));
            final FileOutputStream fileOutput = new FileOutputStream(tempFile);
            final BufferedOutputStream bufferedOutput = new
BufferedOutputStream(fileOutput, 1024);
            final DataOutputStream dataOutput = new
DataOutputStream(bufferedOutput);

            try {
                for(int i = 0; i < size; i++) {
                    tagStruct tag = tags.get(i);
                    dataOutput.writeInt(size);
                    dataOutput.writeFloat(tag.mXcoord);
                    dataOutput.writeFloat(tag.mYcoord);
                    Utils.writeUTF(dataOutput, tag.mTag);
                }

                if(dataOutput != null) {
                    dataOutput.close();
                    bufferedOutput.close();
                    fileOutput.close();
                }
            } catch (Exception e) {
                // Was unable to perform the operation, we delete the temp file
                Log.e(TAG, "Unable to write the index file " + crc64);
                tempFile.delete();
            }
        }catch(IOException e) {
            e.printStackTrace();
        }
    }

-------------------------------------------------------------------------------------------------
my read code
    public static ArrayList<tagStruct> createFBTagFromCache(long crc64) {
        Log.e("harvey", "create facebook tag from cache");
        try {
            File tempFile = null;
            final String tempFilePath = FB_TAG_CACHE;
            String prefix = crc64 + "";
            tempFile = File.createTempFile(prefix, ".cache", new
File(tempFilePath));

            FileInputStream fileInput = new FileInputStream(tempFile);
            BufferedInputStream buf = new BufferedInputStream(fileInput);
            final DataInputStream dataInput = new DataInputStream(buf);

            try {
                int size = dataInput.readInt();
                ArrayList<tagStruct> tags = new ArrayList<tagStruct>(size);
                for(int i = 0; i < size; i++) {
                    tagStruct tag = new tagStruct();
                    if(i!=0) {
                        int laji = dataInput.readInt();
                    }
                    tag.mXcoord = dataInput.readFloat();
                    tag.mYcoord = dataInput.readFloat();
                    tag.mTag = dataInput.readUTF();
                    tags.add(tag);
                }
                dataInput.close();
                return tags;
            } catch (Exception e) {
                dataInput.close();
                return null;
            }
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
---------------------------------------------------------------------------------------------
Exceptoin cause following:

05-05 13:32:50.058: WARN/System.err(5268): java.io.EOFException
05-05 13:32:50.058: WARN/System.err(5268):     at
java.io.DataInputStream.readInt(DataInputStream.java:287)
05-05 13:32:50.058: WARN/System.err(5268):     at
com.cooliris.media.UriTexture.createFrTagFromCache(UriTexture.java:455)
05-05 13:32:50.058: WARN/System.err(5268):     at
com.cooliris.media.UriTexture.createFromUri(UriTexture.java:185)
05-05 13:32:50.058: WARN/System.err(5268):     at
com.cooliris.media.UriTexture.load(UriTexture.java:362)
05-05 13:32:50.058: WARN/System.err(5268):     at
com.cooliris.media.RenderView.loadTextureAsync(RenderView.java:308)
05-05 13:32:50.058: WARN/System.err(5268):     at
com.cooliris.media.RenderView.access$6(RenderView.java:306)
05-05 13:32:50.058: WARN/System.err(5268):     at
com.cooliris.media.RenderView$TextureLoadThread.load(RenderView.java:1176)
05-05 13:32:50.058: WARN/System.err(5268):     at
com.cooliris.media.RenderView$TextureLoadThread.run(RenderView.java:1160)
05-05 13:32:50.259: WARN/System.err(5268): java.io.EOFException
05-05 13:32:50.259: WARN/System.err(5268):     at
java.io.DataInputStream.readInt(DataInputStream.java:287)
05-05 13:32:50.259: WARN/System.err(5268):     at
com.cooliris.media.UriTexture.createFrTagFromCache(UriTexture.java:455)
05-05 13:32:50.259: WARN/System.err(5268):     at
com.cooliris.media.UriTexture.getTag(UriTexture.java:689)
05-05 13:32:50.259: WARN/System.err(5268):     at
com.cooliris.media.RenderView.drawTag(RenderView.java:251)
05-05 13:32:50.259: WARN/System.err(5268):     at
com.cooliris.media.RenderView.uploadTexture(RenderView.java:613)
05-05 13:32:50.259: WARN/System.err(5268):     at
com.cooliris.media.RenderView.processTextures(RenderView.java:580)
05-05 13:32:50.259: WARN/System.err(5268):     at
com.cooliris.media.RenderView.onDrawFrame(RenderView.java:755)
05-05 13:32:50.259: WARN/System.err(5268):     at
android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
05-05 13:32:50.259: WARN/System.err(5268):     at
android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

-------------------------------------------------------------------------
why??

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to