java - ClassNotFoundException happens during calling ObjectInputStream.readobject in Android -
i want read object android internal storage.
the following code. write static function reading object file in same class. no idea why exception happen . appreciate if give suggestions.
thanks.
package com.crescent.programmercalculator; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.objectinputstream; import java.io.objectoutputstream; import java.io.serializable; import android.util.log; import android.content.context; public class calculateconfigurations implements serializable{ static string configlocation="configfile"; public short radix; calculateconfigurations(){ radix=16; } public static calculateconfigurations loadobjectfromfile(context context){ try { fileinputstream fis = context.openfileinput(configlocation); objectinputstream = new objectinputstream(fis); calculateconfigurations config = (calculateconfigurations) is.readobject(); is.close(); fis.close(); return config; } catch (filenotfoundexception e) { // first use case log.v("calculateconfigurations", "first init configuration file"); return new calculateconfigurations(); } catch (ioexception e) { e.printstacktrace(); log.e("calculateconfigurations", "fatal error, configuration file may broken"); return new calculateconfigurations(); } catch (classnotfoundexception e) { e.printstacktrace(); log.e("calculateconfigurations", "fatal error, unknown"); return new calculateconfigurations(); } } }
classnotfoundexception
this in cases mixup in xml-files. if post both stacktrace , proper xml-file, easy fix it!
Comments
Post a Comment