Byte[] serialization/deserialization BLOB problem

I want to store an image in DB.
I choose to store a byte[], like a BLOB (i use MySql).
But when byte[] is serialized in DB in front of the array are inserted 27
bytes.
What should i do to store exact the given byte array ?
(Or off course an ImageIcon object : for which on deserialization an
ClassCastException is thrown).
And which is the reason that those 27 (!?!) bytes are inserted.
thank you in advance for your help.
(please excuse my english)
BytesTest.jdo
<?xml version="1.0"?>
<!DOCTYPE jdo SYSTEM "http://www.solarmetric.com/dtds/jdo.dtd">
<!-- This JDO Metadata file was auto-generated on 7/2/02 3:18 PM.
See http://www.solarmetric.com for Kodo JDO Documentation and examples. -->
<jdo>
<package name="jdoproject">
<class name="BytesTest" requires-extent="true">
<field name="bytesArray" null-value="none" primary-key="false">
<extension key="blob" value="true" vendor-name="kodo"/>
</field>
</class>
</package>
</jdo>
BytesTest.java
package jdoproject;
public class BytesTest {
private byte[] bytesArray = null;
public BytesTest () {
bytesArray = new byte[30];
for (int i = 0; i < 30; i++)
bytesArray[i] = (byte)(65 + i);
public String toString () {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < bytesArray.length; i++)
sb.append(" " + (bytesArray[i] & 0xFF) + "[" +
(char)(bytesArray[i] & 0xFF)
+ "]");
return sb.toString();
this must be run twice (first , to make an insertion , second to view what
is previos inserted)
BytesTestMain.java
public class BytesTestMain {
public static void main (String[] args) {
BytesTest test = null;
try {
JDBCConfiguration jc = new JDBCPropertiesConfiguration();
PersistenceManagerFactory pmf = new
JDBCPersistenceManagerFactory(
new FileInputStream("config/kodo.properties"));
PersistenceManager pm = pmf.getPersistenceManager();
Extent people = pm.getExtent(BytesTest.class, false);
Query query = pm.newQuery(BytesTest.class, people);
Collection result = (Collection)query.execute();
Iterator iter = result.iterator();
System.out.println("Found items: ");
while (iter.hasNext()) {
test = (BytesTest)iter.next();
System.out.println("test= " + test);
test = new BytesTest();
System.out.println("Inserting item: "+test);
Transaction t = pm.currentTransaction();
t.begin();
pm.makePersistent(test);
t.commit();
} catch (Exception e) {
e.printStackTrace();
System.out.println("ALL DONE---------------------");

cross-post:
http://forum.java.sun.com/thread.jsp?forum=31&thread=323525

Similar Messages

  • SOS!Serialization/Deserialization in Web Services!!!!!

    Hello, I have done some serialization/deserialization jobs before which is just about JavaBeans, but when it comes to Object Arrays, errors occured when the problem become more complex.Suppose I have an Object Array called params, nd params[0] is a JavaBean instance,params[1] is a String, while params[2] is a Float. I have tried many times, but the serialization works still failed.So anyone having met and solved such problem please share your code with me(my email is [email protected]), thanks very very much!

    Hi
    Elvez,
        Thanks for answering.I have created the web service client jar file through the NW studio standalone proxy wizrd which creates a jar file so that external java application can invoke the web service outside of the portal. The web service is called dynamically by the following code ...
    TestService service = new TestServiceImpl();
    TestBindingStub port = (TestBindingStub)service.getTestService();
    Pip3A2PriceAndAvailabilityRequest   request  = new Pip3A2PriceAndAvailabilityRequest();
    populateRequest( request );
    Pip3A2PriceAndAvailabilityResponse  response = port.getInventory( request );
    If I have issued Netweaver Studio to both publish the service as well as to consume the web service, I think then the issue is on the client side wizard which creates the proxy classes for the web service client in the jar file. The wsdl specifies the xml namespace for the Arrays but the generated client code probably is not setting the name space correctly.
    Thanks
    Bhabesh Patel

  • How to improve the performance of serialization/deserialization?

    Hi, Friends,
    I have a question about how to improve the performance of serialization/deserialization.
    When an object is serialized, the entire tree of objects rooted at the object is also serialized. When it is deserialized, the tree is reconstructed. For example, suppose a serializable Father object contains (a serializable field of) an array of Child objects. When a Father object is serialized, so is the array of Child objects.
    For the sake of performance consideration, when I need to deserialize a Father object, I don't want to deserialize any Child object. However, I should be able to know that Father object has children. I should also be able to deserialize any child of that Father object when necessary.
    Could you tell me how to achieve the above idea?
    Thanks.
    Youbin

    You could try something like this...
    import java.io.*;
    import java.util.*;
    class Child implements Serializable {
        int id;
        Child(int _id) { id=_id; }
        public String toString() { return String.valueOf(id); }
    class Father implements Serializable
        Child[] children = new Child[10];
        public Father() {
         Arrays.fill(children, new Child(1001));
        public void readObject(ObjectInputStream stream)
         throws IOException, ClassNotFoundException
         int numchildren = stream.readInt();
         for(int i=0; i<numchildren; i++)
             children[i] = (Child)stream.readObject();
         stream.close();
        public void writeObject(ObjectOutputStream stream) throws IOException
         stream.writeInt(children.length);
         for(int i=0; i<children.length; i++)
             stream.writeObject(children);
         stream.close();
    Child[] getChildren() { return children; }
    class FatherProxy
    int numchildren;
    String filename;
    public FatherProxy(String _filename) throws IOException
         filename = _filename;
         ObjectInputStream ois =
         new ObjectInputStream(new FileInputStream(filename));
         numchildren = ois.readInt();
         ois.close();
    int getNumChildren() { return numchildren; }
    Child[] getChildren() throws IOException, ClassNotFoundException
         ObjectInputStream ois =
         new ObjectInputStream(new FileInputStream(filename));
         Father f = (Father)ois.readObject();
         ois.close();     
         return f.getChildren();
    public class fatherref
    public static void main(String[] args) throws Exception
         // create the serialized file
         Father f = new Father();
         ObjectOutputStream oos =
         new ObjectOutputStream(new FileOutputStream("father.ser"));
         oos.writeObject(f);
         oos.close();
         // read in just what is needed -- numchildren
         FatherProxy fp = new FatherProxy("father.ser");
         System.out.println("numchildren: " + fp.getNumChildren());
         // do some processing
         // you need the rest -- children
         Child[] c = fp.getChildren();
         System.out.println("children:");
         for(int i=0; i<c.length; i++)
         System.out.println("i " + i + ": " + c[i]);

  • Custom serializer/deserializer in Weblogic 9 web service

    We are able to select XML from the database which is properly formatted to the schema definition of the method return type. Therefore, the serialization/deserialization of XML to JAVA and then back to XML does not make sense.
    Is there a way to use a custom serializer/deserializer in a Weblogic 9.1 web service like we could do in Weblogic 8.1? I have read where the 8.1 web services are still supported but we would like to migrate everything over now. In 8.1 the serializer/deserializer was defined in the deployment descriptor. However, I have seen nothing of this kind in Weblogic 9 documentation and all of those classes are now marked Deprecated.
    Any help is greatly appreciated. Thanks!

    Why dont you try removing the ejb-jar.xml and using annotations. You can use @JndiName and @FileGeneration annotations, this should work ...
    -Jesus

  • GET WRONG with ICON serialization/deserialization!!!

    GET WRONG with ICON serialization/deserialization!!!
    I have my own class X, which implements Serializable.
    My own class X contains an Icon and a String!
    I've created an obj (type X) !
    set its Icon = UIManager.getIcon("Tree.closedIcon);
    set its String = "yyyy";
    i 've serialized it , and then deserialized , read it into my new var !
    (my new var is also X obj!)
    i've debugged my code : the Icon field and the String in my new var had
    new values !
    ( the new values are not null ,and seem to be the original values)!
    But when i put those values into a jLabel ,
    the label show just the String !
    i dont know how to over come it !
    plz help ...

    it's me urgent !
    plz help !

  • Serialization/Deserialization Error

    Hi..my aim is to serialize/deserialize my "SoapPair" class , that contains Axis MessageContext obj (SoapPair receives this from its constructor), not serializable object(when trying to normally serialize , it returns "axis MessageContext not serializable")..
    How do I serialize/deser the SoapPair class?
    Do I have to use SerializationContext/Deser context? How?
    Thanks in Advance.

    This forum for Networking and has nothing to do with axis Serialization.
    I am not sure if I remember axis has a deployment descriptor for the web service and there you can define you Serialize/Dez your bean if you do not want to use the default one or you can specify for certain class a serialize/Dez factory serializer.
    Regards,
    Alan Mehio
    London,UK

  • Serialization/Deserialization Error - Axis

    Hi..my aim is to serialize/deserialize my "SoapPair" class , that contains Axis MessageContext obj (SoapPair receives this from its constructor), not serializable object(when trying to normally serialize , it returns "axis MessageContext not serializable")..
    How do I serialize/deser the SoapPair class?
    Do I have to use SerializationContext/Deser context? How?
    Thanks in Advance.

    This forum for Networking and has nothing to do with axis Serialization.
    I am not sure if I remember axis has a deployment descriptor for the web service and there you can define you Serialize/Dez your bean if you do not want to use the default one or you can specify for certain class a serialize/Dez factory serializer.
    Regards,
    Alan Mehio
    London,UK

  • Blob Problem

    Hello,
    The problem that i have is that i want to insert a file residing in the network into the oracle database into a blob field and again read it from the database and show it ie either insert it into a file directly and then open it using the correct editor or open it directly. I am using java along with it but i am basically stuck on the database side.
    I am sending the code which i have written till date
    i basically need to know
    1)the syntax i am using to interact with the database is right ie where is the error in the code
    2)provided that is ok whether my overall code is on the right track.
    The error message i am getting:
    java.sql.exe:ORA-06550 line col22
    PLS 00302: Component GETCHUNKSIZE must be declared
    ORA-06550 line1 col 7
    pl/sql statement ignoured
    My developopment enviornment is JDeveloper3.0 as this code is having problems compiling in JDK as Jdeveloper overides a few of the jdk classes.
    =========================================================================
    My table structure
    CREATE TABLE DOC_MAS(
    DOC_MAS_SR_NO NUMBER(10),
    PROJECT_NAME VARCHAR2(30),
    MODULE_NO NUMBER(10),
    DOC_NAME VARCHAR2(10),
    DOC_TYPE VARCHAR2(10),
    VERSION NUMBER(10));
    CREATE SEQUENCE SEQ_DOC_MAS START WITH 1 INCREMENT BY 1;
    CREATE SEQUENCE SEQ_DOC_DETAIL START WITH 1 INCREMENT BY 1;
    CREATE TABLE DOC_DETAIL(
    DOC_DETAIL_SR_NO NUMBER(10),
    DOC_MAS_SR_NO NUMBER(10),
    DATE_OF_INSERT DATE,
    ACTUAL_DOC BFILE,
    COMMENTS VARCHAR2(500));
    ===============================================================================
    My connection code:
    public class ConnectionParams {
    // The machine on which the database resides
    //public final static String s_hostName = "insn110a.in.oracle.com";
    public final static String s_hostName = "192.168.1.1";
    // The TNS listener port
    public final static String s_portNumber = "1521";
    // The database name (SID)
    //public final static String s_databaseSID = "otndb";
    public final static String s_databaseSID = "orcl";
    // The database User ID
    public final static String s_userName = "scott";
    // The database user password
    public final static String s_password = "tiger";
    ========================================================================================
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    import java.util.*;
    import java.util.Date;
    //import java.math.BigDecimal;
    public class Sample2
    Connection m_connection; //Database Connection Object
    String p_doc_name=null;
    String s_blobvariable = p_doc_name;
    public Sample2()
    dbConnection();
    public static void main(String[] args)
    Sample2 lobs = new Sample2();
    // lobs.dbConnection();
    lobs.readFileNameExt();
    /*This class is for creation of connection =========================================*/
    public void dbConnection() {
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    String l_dbConnectString =
    "(DESCRIPTION=(ADDRESS=(HOST="+ConnectionParams.s_hostName+")"+
    "(PROTOCOL=tcp)(PORT="+ConnectionParams.s_portNumber+"))"+
    "(CONNECT_DATA=(SID="+ConnectionParams.s_databaseSID+")))";
    m_connection = DriverManager.getConnection(
    "jdbc:oracle:thin:@"+l_dbConnectString,
    ConnectionParams.s_userName, ConnectionParams.s_password);
    // m_connection.setAutoCommit(false);
    System.out.println("Connection Successful");
    Thread.sleep(3000);
    } catch(Exception ex){ //Trap SQL errors
    System.out.println("Error in Connecting to the Database "+ex.toString());
    /*========================================================================================
    File inserting section of the code
    // THIS class gets the input from the file dialog box it gets the file path,projectName and the module no
    //public void readFileNameExt(String p_doc_path,String p_module_no,String p_project_name)
    public void readFileNameExt()
    String p_doc_path = "c:/warea/Mehul2/TABLE5.xls";
    int p_module_no = 10;
    String p_project_name = "Finserve";
    String p_doc_type= null;
    String p_version = null;
    StringTokenizer strtkn = new StringTokenizer(p_doc_path,"/");
    while(strtkn.hasMoreTokens())
    p_doc_name =strtkn.nextToken();
    System.out.println("The file name is" +p_doc_name);
    StringTokenizer strtoken = new StringTokenizer(p_doc_name,".");
    while(strtoken.hasMoreTokens())
    p_doc_type =strtoken.nextToken();
    try{
    System.out.println("The file Type is"+p_doc_type);
    insertDocMas(p_doc_name,p_doc_type,p_project_name,p_module_no);
    Thread.sleep(10000);
    }catch (Exception e){}
    }//end of method
    //============================================== this class is for inserting the doc_mas details in teh table along with version checking
    public void insertDocMas(String p_doc_name,String p_doc_type,String p_project_name,int p_module_no){
    int p_version = -1;
    int p_doc_mas_sr_no = -1;
    // String verision=null;
    int verision;
    String s = null;
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_version_details = l_stmt.executeQuery("SELECT MAX(VERSION) FROM DOC_MAS WHERE DOC_NAME = '"+p_doc_name+"'");
    if (l_version_details.next())
    { System.out.println("The Control 1");
    verision = l_version_details.getInt(1);
    System.out.println("The Control 2 : "+verision);
    verision = verision +1;
    else {
    verision = 1;
    System.out.println("The Control 3");
    p_version = verision;
    System.out.println("The value of p_version" + p_version);
    l_version_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert"+e);
    /* try{
    Statement stmt = m_connection.createStatement();
    ResultSet rset = stmt.executeQuery("select DEPTNO,DNAME,LOC from DEPT");
    while(rset.next()){
    BigDecimal deptno = rset.getBigDecimal(1,2);
    String dname = rset.getString(2);
    // Timestamp hiredate = rset.getTimestamp(3);
    String loc = rset.getString(3);
    System.out.println(deptno+" "+dname+" "+loc);
    Thread.sleep(50000);
    }catch(Exception e){System.out.println(e);}
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_seq_details = l_stmt.executeQuery("SELECT SEQ_DOC_MAS.NEXTVAL FROM DUAL");
    if (l_seq_details.next())
    p_doc_mas_sr_no = l_seq_details.getInt(1);
    System.out.println("The Control AA");
    System.out.println("The value of p_doc_mas_sr_no" + p_doc_mas_sr_no);
    l_seq_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of selecting the current sequence number"+e);
    try {
    System.out.println("Creating rows in DOC_MAS.. ");
    System.out.println("The Control VV");
    PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_MAS(DOC_MAS_SR_NO,PROJECT_NAME,MODULE_NO,DOC_NAME,DOC_TYPE,VERSION) values(?,?,?,?,?,?)");//SEQ_DOC_MAS.nextval
    l_pstmt.setInt(1,p_doc_mas_sr_no);//"SEQ_DOC_DETAIL.NEXTVAL"
    l_pstmt.setString(2,p_project_name);
    l_pstmt.setInt(3,p_module_no);
    l_pstmt.setString(4,p_doc_name);
    l_pstmt.setString(5,p_doc_type);
    l_pstmt.setInt(6,p_version);
    l_pstmt.executeUpdate(); // Execute SQL statement
    l_pstmt.close();
    System.out.println("The Control 3");
    // Close statement
    Thread.sleep(20000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert11"+e);
    try{System.out.println("The Control 4");
    Statement l_statement = m_connection.createStatement();
    ResultSet l_doc_mas_sr_no = l_statement.executeQuery(
    "SELECT max(DOC_MAS_SR_NO) FROM DOC_MAS "+
    "WHERE DOC_NAME = '"+p_doc_name+"' ");//FOR UPDATE
    if (l_doc_mas_sr_no.next())
    p_doc_mas_sr_no = l_doc_mas_sr_no.getInt(1);
    l_doc_mas_sr_no.close();
    l_statement.close();
    System.out.println("The Control 5");
    Thread.sleep(10000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert");
    loadSamples(p_doc_mas_sr_no,p_doc_name,p_doc_type);
    }//Method insertDocMas() closing here
    /*This class is for loading the data into the database==================================*/
    public void loadSamples(int p_doc_mas_sr_no,String p_doc_name,String p_doc_type) {
    int p_doc_detail_sr_no = -1;
    Date p_sysdate = new Date() ;
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_seq_doc_details = l_stmt.executeQuery("SELECT SEQ_DOC_DETAIL.NEXTVAL FROM DUAL");
    if (l_seq_doc_details.next())
    p_doc_detail_sr_no = l_seq_doc_details.getInt(1);
    System.out.println("The Control AA");
    System.out.println("The value of p_doc_detail_sr_no" + p_doc_detail_sr_no);
    l_seq_doc_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of selecting the current sequence number"+e);
    try{
    Statement l_st = m_connection.createStatement();
    ResultSet l_date = l_st.executeQuery("SELECT sysdate FROM DUAL");
    if (l_date.next())
    p_sysdate = l_date.getDate(1);
    System.out.println("The Control sysdate");
    System.out.println("The value of p_sysdate" + p_sysdate);
    l_date.close();
    l_st.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of selecting the sysdate"+e);
    try {System.out.println("The Control 6");
    System.out.println("Creating row for actual-doc in DOC_DETAILS.. ");
    PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_DETAIL(DOC_DETAIL_SR_NO,DOC_MAS_SR_NO,DATE_OF_INSERT,ACTUAL_DOC)values(?,?,p_sysdate, empty_blob() )");
    l_pstmt.setInt(1,p_doc_detail_sr_no);
    l_pstmt.setInt(2,p_doc_mas_sr_no);
    //l_pstmt.setDate(3,p_sysdate);
    System.out.println("The Control 6AA");
    l_pstmt.execute(); // Execute SQL statement
    l_pstmt.close(); // Close statement
    System.out.println("Created.\nLoading <map.gif> into BLOB column for doc_detail...");
    System.out.println("The Control 7");
    // Retrieve the row just inserted, and lock it for insertion of the
    }catch(Exception e){
    System.out.println("Exception has occured at the time of inserting blob locators"+e);
    try {
    // LOB columns.
    System.out.println("The Control 7AAA");
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_lobDetails = l_stmt.executeQuery(
    "SELECT ACTUAL_DOC "+
    "WHERE DOC_MAS_SR_NO = '"+p_doc_mas_sr_no+"'");
    // Retrieve BLOB and CLOB streams for ACTUAL_DOC and TEXT_DOC
    // columns, and load the sample files
    System.out.println("The Control 8");
    if (l_lobDetails.next())
    // Get the BLOB locator and open output stream for the BLOB
    BLOB l_mapBLOB = ((OracleResultSet)l_lobDetails).getBLOB(1);
    OutputStream l_blobOutputStream = l_mapBLOB.getBinaryOutputStream();
    System.out.println("The Control 9");
    // Open the sample file as a stream for insertion into the BLOB column
    File l_blobvariable = new File(s_blobvariable);
    InputStream l_sampleFileStream=new FileInputStream(l_blobvariable);
    System.out.println("The Control 10");
    // Buffer to hold chunks of data to being written to the BLOB.
    // In Oracle8.1.5 JDBC drivers a method getBufferSize() is available
    // in the BLOB class, that returns the optimal buffer size
    byte[] l_buffer = new byte[10* 1024];
    System.out.println("The Control 11");
    // Read a chunk of data from the sample file input stream, and write the
    // chunk to the BLOB column output stream. Repeat till file has been
    // fully read.
    int l_nread = 0; // Number of bytes read
    while ((l_nread= l_sampleFileStream.read(l_buffer)) != -1) // Read from file
    l_blobOutputStream.write(l_buffer,0,l_nread); // Write to BLOB
    System.out.println("The Control 12");
    // Close both streams
    l_sampleFileStream.close();
    l_blobOutputStream.close();
    System.out.println("Done Loading sample files");
    System.out.println("\nRetrieving and displaying sample files..");
    // Retrieve and display the LOB data just inserted
    drawBLOB(l_mapBLOB,p_doc_name,p_doc_type);
    //System.out.println("Done loading and displaying LOB data");
    } //if statement closes here
    l_lobDetails.close();// Close Result Set and statement
    l_stmt.close();
    } catch (Exception ex)
    { // Trap       SQL errors
    System.out.println("Error loading sample files for the selected airport");
    System.out.println("\n"+ex.toString());
    }//Method closes here
    * Retrieve the BLOB data from input BLOB column into a local file,
    * and draws the image. The file type needs to be added here
    public void drawBLOB(BLOB p_blob, String p_doc_name,String p_doc_type) {
    //String fileType this should be passed at some point to ensure that the file gets the right extension
    try {
    // Open a stream to read the BLOB data
    InputStream l_blobStream = p_blob.getBinaryStream();
    // Open a file stream to save the BLOB data
    FileOutputStream l_fileOutStream = new FileOutputStream(p_doc_name+"."+p_doc_type);
    // Read from the BLOB data input stream, and write to the file output
    // stream
    byte[] l_buffer = new byte[10]; // buffer holding bytes to be transferred
    int l_nbytes = 0; // Number of bytes read
    while ((l_nbytes = l_blobStream.read(l_buffer)) != -1) // Read from BLOB stream
    l_fileOutStream.write(l_buffer,0,l_nbytes); // Write to file stream
    // Flush and close the streams
    l_fileOutStream.flush();
    l_fileOutStream.close();
    l_blobStream.close();
    //m_GUI.drawMap(p_doc_name,p_doc_type);
    // Draw retrieved image to GUI
    drawMap(p_doc_name,p_doc_type);
    } catch (Exception ex) { // Trap SQL and IO errors
    System.out.println("Error in retrieving and drawing map for selected airport");
    System.out.println("\n"+ex.toString());
    * Create a label from the image filepassed, add the label to the image area
    This part will have to be modified majorly
    public void drawMap(String p_doc_name,String p_doc_type) {
    //Refer to SIRExtOpen.java
    Runtime r = Runtime.getRuntime();
    Process p = null;
    if (p_doc_type.equals("html")&#0124; &#0124;p_doc_type.equals("htm"))
    try{
    p = r.exec( "C:\\Program Files\\Internet Explorer\\Iexplore.EXE " + p_doc_name);
    //repaint();
    p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    if(p_doc_type.equals("txt")&#0124; &#0124; p_doc_type.equals("sql")&#0124; &#0124; p_doc_type.equals("java"))
    try
    p = r.exec( "C:\\WINDOWS\\notepad.EXE " + p_doc_name); p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of txt , sql , java if
    if(p_doc_type.equals("xls"))
    try
    p = r.exec( "C:\\Program Files\\Microsoft Office\\Office\\excel.EXE " + p_doc_name);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of xls if
    if(p_doc_type.equals("fmb"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + p_doc_name);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of fmb if
    if(p_doc_type.equals("doc"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + p_doc_name);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of doc if
    if(p_doc_type.equals("mpp"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + p_doc_name);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of mpp if
    //Here you can write a statement for deleting the file in the root directory once the file is opened using any editor
    }//end of method
    }//This is the class closing
    * This method is called when a row is selected from the combo.
    * It checks if there exists data in DOC_DETAIL for the selected
    * file. If there exists data, it calls drawBLOB and writeCLOB to
    * display the data
    /*public void fileSelected(String p_doc_mas_sr_no,String p_doc_name,String p_doc_type) {
    try {
    System.out.println("Retrieving LOB details for selected file..");
    // Create a SQL statement
    Statement l_stmt = m_connection.createStatement();
    // Query DOC_DETAILS for the selected file
    java.sql.ResultSet l_lobDetails = l_stmt.executeQuery(
    "SELECT ACTUAL_DOC FROM DOC_DETAILS "+
    "WHERE DOC_MAS_SR_NO='"+p_doc_mas_sr_no+"'");
    // Check if LOB columns exist
    if (l_lobDetails.next()) {
    // LOB details exist
    // Display airport map and suggestion book (LOB details)
    drawBLOB(l_lobDetails.getBlob(1),p_doc_name,p_doc_type);
    //lobs.drawBLOB(((OracleResultSet)l_lobDetails).getBLOB(1),p_doc_name,p_doc_type);
    //Should this be like this
    System.out.println("Done retrieving and displaying LOB details");
    } else {
    // No LOB details
    // m_GUI.m_loadButton.setEnabled(true);
    //TO BE CHECKED OUT LATER m_loadButton This is a button in the form
    System.out.println("No airport map and suggestion book exist for selected airport");
    System.out.println("\nPress <Load Sample2 Files> to load LOB details");
    l_lobDetails.close();
    l_stmt.close();
    } catch (Exception ex) { // Trap SQL errors
    System.out.println("Error retrieving LOB Details for the selected airport");
    System.out.println(ex.toString());

    You are probably better off using BLOBs rather than BFILEs. The main reason for this is that with BLOBs data integrity between file and its meta data in the database are managed and protected by the RDBMS. BFILEs are useful for legacy systems where the files already exist in some form of meaningful and managed structure that needs to be preserved.
    There is a down side to BLOBs and that is performance - BLOBs are relatively slow to load into the database. However, its not too bad and the performance of extracting BLOBs out from the database is quite reasonable the bottleneck is more likely to be your LAN.
    In order to use BLOBs it is important to have the right class libraries involved. For BLOBs you must use the classes12.zip (supplied with the database) for JDBC2 support and furthermore put this class high up the list of class libraries if you do not you may find that your code compiles but raises a runtime exception about invalid data types; this is because the wrong definition of the Blob class is being picked up.
    Assuming that you are using BLOBs then the following describes the techniques for storing files as BLOBs in an Oracle database.
    LOADING BLOBS
    Assuming that you have a table with a BLOB column in it then to load a BLOB you must first create the record containing the BLOB by inserting a row into your table with the value of the BLOB column set to EMPTY_BLOB( ) (PL/SQL built in):
    INSERT INTO tablex( col1, col2, colBLOB )
    VALUES( val1, val2, EMPTY_BLOB() )
    Then you must row lock this record and obtain the LOB locator for the BLOB just created:
    stmt = connection.createStatement();
    query = "SELECT colBLOB FROM tablex WHERE ... FOR UPDATE OF colBLOB";
    ResultSet lockLOBSet = stmt.executeQuery(query);
    At this point you should be able to use lockLOBSet.getBlob(1) to create a binary stream to load the BLOB directly into the database. Under Java Developer 2 I could never get this to work and havent tried since with Java Developer 3. Instead I used the PL/SQL DBMS_LOB package and did it using JDBC; this assumes that the file has been loaded into a buffer binaryFile and note that the maximum chunk size that dbms_lob.write can be called with is 32K:
    blobLoc = lockLOBSet.getBlob(1);
    while(amountWritten < fileSize)
    if ((amountWritten + writeAmount) <= fileSize)
    writeAmount = 32000;
    else
    writeAmount = fileSize - amountWritten;
    System.arraycopy(binaryFile, amountWritten, buffer, 0, writeAmount);
    CallableStatement cstmt =
    connection.prepareCall("{call dbms_lob.write(?, ?, ?, ?)}");
    cstmt.setBlob(1, blobLoc);
    cstmt.setLong(2, writeAmount);
    cstmt.setLong(3, amountWritten + 1);
    cstmt.setBytes(4, buffer);
    cstmt.execute();
    cstmt.close();
    amountWritten = amountWritten + writeAmount;
    EXTRACTING BLOBS
    Binary streams do work when it comes to reading BLOBs out of the database so things are a whole lot simpler probably worth trying it with loading BLOBs now as well.
    ResultSet queryLOBSet = statement.executeQuery(query);
    if(queryLOBSet.next())
    lobSize = queryLOBSet.getInt(1);
    blobLoc = queryLOBSet.getBlob(2);
    BufferedInputStream bi;
    blobBuffer = new byte[lobSize];
    bi = new BufferedInputStream(blobLoc.getBinaryStream());
    amountRead = bi.read(blobBuffer);
    bi.close();
    Regards,
    Bob
    null

  • Deserialization order problem

    Hi,
    For a game i am making i am storing the map as a Serialized Object.
    The problem is when i try to paint an image (which should be loaded in the constructor) it is null and thus causing a nullpointer. This only happens after serializing and deserializing the Map. It appears to me that somehow the constructors are not called anymore.
    I am using the following (simplified) objects:
    public class Map implements java.io.Serializable
         //also included are some protected final static primitives
         protected MapModel model;
         //and some other protected primitives and objects     
         public Map()
              this(null);
         public Map(MapModel model)
              this.model=model;
    public class MapModel implements java.io.Serializable
         protected Terrain[][] data;
         private Size size;//simple serializable class
         public MapModel()
              this(new Size());
         public MapModel(Size s)
              data=new Terrain[s.width][s.height];
              size=s;
    public abstract class Terrain implements java.io.Serializable
         protected transient Image view;     
         //some more protected primitives     
         public Terrain()
              this(Allignment.SOUTHWEST);
         public Terrain(int allignment)
              System.out.println("Terrain constructor: "+getClass().getName());
              view=loadImage();
         protected abstract Image loadImage();
         //some more abstract methods
    public abstract class Tile extends Terrain
         //some public final static ints     
         //some protected ints
         public Tile()
              this(Allignment.SOUTHWEST);
         public Tile(int allignment)
              super(allignment);
              System.out.println("Tile constructor");
         //loadImage() is still not implemented
    public class GreyTile extends Tile
         public GreyTile()
              this(Allignment.SOUTHWEST);
         public GreyTile(int allignment)
              super(allignment);
              System.out.println("GreyTile constructor");
         protected java.awt.Image loadImage()
              System.out.println("GreyTile loadImage()");
              //load and return an image
    }The above object tree is created and serialized and produces the expected output:
    Terrain constructor: heroquest.terrain.tiles.GreyTile
    GreyTile loadImage()
    Tile constructor
    GreyTile constructor
    Deserialization however does not produce any output, so loadImage is never called and Terrain.view is null. Which explains the Nullpointer i am getting when trying to paint the GreyTile.
    However i do not understand why my constructors are never called.
    any thoughts?
    Thanks,
    Mr Mean

    This image is loaded in the constructor. And the
    problem is that after deserialization the constructor
    is never exectued.
    My Question is why.First of all, I apologize for not reading through your code thoroughly. Yes your Image object is transient.
    A Ctor is called only when a new instance is created. When deserializing, we are not creating a new instance , we are only restoring a persisted object.
    The deserialization process does not use the Ctor because it is not needed. The only time it needs a Ctor is when deserializing the state of the first non-serializable superclass of a serializable one (deserialization needs to reconstruct the entire object state, which includes the state of any superclasses. If the superclass is not itself serializable, then deserialization needs to instantiate that superclass from scratch ).That superclass won't be restored from the stream, but by invoking that class' no-argument constructor.
    If the default behavior of this process does not suit your purposes, the solution would be to provide your own writeObject/readObject methods to do what you need to do.

  • 2.3.0b3 and PointBase Blob problem.

    The schema tool generates a BLOB with a maxsize of 1 byte in PointBase for
    fields with the "blob" extension. This is of course too small, and results
    in a "data right truncation" exception (from PointBase), when an insert is
    attempted. The column-length extension element does not affect the BLOB
    size. Is there some workaround?
    -Maciej Szefler

    I'm experiencing some additional problems with PointBase. It seems that the
    "drop" action in schema tool does not work correctly (the syntax for
    dropping the indexes is incorrect):
    $ schematool -action drop classes/com/fs/wf/impl/jdo/package.jdo
    Exception in thread "main" java.sql.SQLException: Expected to find "."
    instead f
    ound "end of SQL command" at position 41.
    at com.pointbase.dbexcp.dbexcpException.getSQLException(DashOB3242)
    at com.pointbase.jdbc.jdbcStatement.executeQuery(DashOB3242)
    at com.pointbase.jdbc.jdbcStatement.executeUpdate(DashOB3242)
    at
    com.solarmetric.kodo.impl.jdbc.datasource.StatementImpl.executeUpdate
    (Unknown Source)
    at
    com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.executeSQL(Unknown Source)
    at
    com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.dropTable(Unknown Source)
    at
    com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.dropTables(Unknown Source)
    at com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.drop(Unknown
    Source)
    at com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.main(Unknown
    Source)
    at com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.main(Unknown
    Source)
    The SQL that caused this error is:
    DROP INDEX REQUESTJDOIMPL__RESPONSESXJDOX;
    DROP INDEX REQUESTJDOIMPL__RESPONSESX_REX;
    DROP TABLE REQUESTJDOIMPL__RESPONSESX;
    DROP TABLE REQUESTJDOIMPLX;
    DELETE FROM JDO_SCHEMA_METADATAX WHERE CLASSNAMEX =
    'com.fs.wf.impl.jdo.RequestJdoImpl';
    DROP INDEX RESPONSEJDOIMPL__PAYLOADXJDOIX;
    DROP TABLE RESPONSEJDOIMPL__PAYLOADX;
    DROP TABLE RESPONSEJDOIMPLX;
    DELETE FROM JDO_SCHEMA_METADATAX WHERE CLASSNAMEX =
    'com.fs.wf.impl.jdo.ResponseJdoImpl';
    This problem is not that big of a deal since dropping the tables drops the
    indexes, but the BLOB column creation issue is a big pain because I have to
    rewrite the SQL in order to increase the BLOB size.
    "Maciej Szefler" <[email protected]> wrote in message
    news:[email protected]...
    The schema tool generates a BLOB with a maxsize of 1 byte in PointBase for
    fields with the "blob" extension. This is of course too small, and results
    in a "data right truncation" exception (from PointBase), when an insert is
    attempted. The column-length extension element does not affect the BLOB
    size. Is there some workaround?
    -Maciej Szefler

  • Serialize/deserialize between Class versions

    I am new at programming.
    I am working on an application that saves serialized classes files. As I make changes to the classes, I can't deserialize old files into the new types. That makes sense to me.
    My question is what makes them compatible or incompatible and is there any to anticipate changes so that I can avoid this problem.
    If I don't change class variables(or something like that) can I remain compatible?
    Thanks,
    LNMEgo

    If I don't change class variables(or something like
    that) can I remain compatible?
    If you define the static final long serialVersionUID to be constant and take care of the serialization versioning, then no problems will arise due to class versioning.
    In general if you only add fields and don't change the order in which they are written or read, the no problems are to be expected. There is also a tutorial on serial persistent fields, which make the whole thing even more 'clean'
    See
    http://java.sun.com/j2se/1.4/docs/guide/serialization/examples/altimpl/index3.html

  • BLOB Problems

    Hi,
    Tough problem it seems.
    I have a database with BLOB datatype and various files of various formats like pdf, office, txt.
    Most of these files blob are properly displayed using the following PHP script
    <?
    $conn = OCILogon ("","","");
    $sql = "";
    $stmt = oci_parse($conn, $sql);
    oci_execute($stmt)
    or die ("Unable to execute query");
    while ($row = oci_fetch_array($stmt)) {
    $id = $row['0'];
    $blob = $row['1'];
    $filename = $row['2'];
    header("Content-type: application/octet-stream");
    header("Content-disposition: attachment; filename=$filename");
    echo "$blob -> readfile()";
    OCIlogoff ($conn);
    ?>
    When the display doesn't work, I have the following characters displayed.
    JAL Ø 'Oh3Â.
    Ä4á Bá Øp | €ÏðH
    # a'hÐ !
    C# ¸«ýÿ
    Ã% Ùt¾a1(TM)Læ"Y'Þq9 Nç"Ùôþ A¡Pè"Z5 Ø¥'€ b H ð /áò m@ - ÂÁÀ ª¾à X£öP 0 'P' ª9oZ%¢vk'~P ²ÞooûÕÞ l# ¤°Ü$/ fÂÃ18l^"J » ±õèÌ8Å--+æaùË<0Ý--
    The most probable problem would be the Byte Order Mark problem known from PHP http://bugs.php.net/42312 but I am not sure.
    I just don't get it. The enconding of the database is ISO. Why some documents are absolutely fine, why some are not?
    Any help would be very much appreciated.
    Edited by: user13013984 on 21 avr. 2010 13:10

    Hi
    Thanks for replying. Data storage seems fine, I have a data presentation issue. The binary cannot be read, the file format isn't recognized.
    When I try the SQL you submitted I get this :
    Erreur SQL : ORA-00932: types de données incohérents : NUMBER attendu ; BINARY obtenu
    00932. 00000 - "inconsistent datatypes: expected %s got %s"
    For example, some word documents stored as long raw work perfectly fine, some cannot be read. No txt files can be read. Some Excel files work fine, some don't.
    There are no Office versions differences between them.
    Is there any tool/code capable of reading any long raw datatype?

  • Converting bytes to character array problem

    I am trying to convert a byte array into a character array, however no matter which Character Set i choose i am always getting the '?' character for some of the bytes which means that it was unable to convert the byte to a character.
    What i want is very simple. i.e. map the byte array to its Extended ASCII format which actually is no change in the bit represtation of the actual byte. But i cannot seem to do this in java.
    Does anyone have any idea how to get around this problem?

    Thanks for responding.
    I have however arrived at a solution. A little un-elegant but it seems to do the job.
    I am converting each byte into char manually by this algorithm:
              for (int i=0;i<compressedDataLength;i++)
                   if (((int) output)<0)
                        k=(127-((int) output[i]));
                        outputChr[i]=((char) k);
                   else
                        k=((int) output[i]);
                        outputChr[i]=((char) k);
                   System.out.println(k);
    where output is the byte array and outputChr is the character array

  • Byte Corseca headset - Charging problem

    Hi,
    I am using byte Corseca bluetooth headset for more than one year. Last  2 months back i got an issue in charging the headset. When i connect the headset to power source (USB Charging) usually i will show the red light glowing constantly. But now it starts blink with in 2-5 sec after i connect it to the power source.
    I am looking for the solution and the service center or any source of help for this but i failed.
    Kindly let me know what should i do now.
    Thanks 
    Murali krishna

    Hi,
    Sorry you're having problems with those headphones.  When you say that you're connecting them to a USB charging power source, does that mean you're plugging the USB cable into your computer?  Or is that USB cable connected to a power outlet?
    You also said it's been happening for 2 months.  Are the headphones still charging, and if so, are you able to use the headphones?
    I would recommend trying a couple different things.  First, if you're plugging those headphones into a computer to charge, try plugging the USB (with adapter) into a wall outlet to see if that affects the charging ability.  
    Next, I would recommend removing those bluetooth headphones from Windows, then try to pair them up again and see if that helps at all.  
    Unfortunately, from what I can see those headphones are pretty much considered "plug and play".  I could not find any documentation on troubleshooting that particular make and model.  I'll keep looking and ask around to see if anyone else has any suggestions that we can try.
    Todd

  • Byte array to base64encoder problem, cannot encode a 7.7 MB file

    hey guys, so ive been trying to use the base64encoder to encode a bytearray which is then sent thru a webservice to the server to be decoded.
    and as the subject of this post suggests, i have been having problems encoding a big file,
    forexample i tried to upload/convert a 84KB image and it worked just fine... the trace of the string ended with a "==" which i believe means that the conversion is complete...
    but when i try to upload a 7.7MB image, it is, i guess, crashing... i dont see any "==" in the string... so i guess its not working... i was wondering if there is any any type of file size limit or soemthign for the encoding...
    the code i have is
    import flash.events.Event;
    import flash.net.FileFilter;
    import flash.net.FileReference;
    import flash.utils.ByteArray;
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.utils.Base64Encoder;
    import services.images.ImageData;
    import services.images.Images;
    import services.images.ReturnMessage;
    // ActionScript file
        public var fileRef:FileReference = new FileReference();
        public var imgCollection:ArrayCollection = new ArrayCollection();
        public var imgService:Images = new Images();
        public var imageData:ImageData = new ImageData();
        public var returnMsg:ReturnMessage = new ReturnMessage();
        public function onBrowseButtonClicked(event:MouseEvent):void{
            var arr:Array = [];
            arr.push(new FileFilter("Images", ".gif;*.jepg;*.jpg;*.png"));
            fileRef.browse(arr);
            fileRef.addEventListener(Event.SELECT, fileRef_select);
            fileRef.addEventListener(Event.COMPLETE, fileRef_complete);
        public function fileRef_select(event:Event):void{
            fileRef.load();
        public function fileRef_complete(event:Event):void{
            img.source = fileRef.data;
            var fileByteArr:ByteArray = fileRef.data;
            var b64En:Base64Encoder = new Base64Encoder();
            b64En.encodeBytes(fileByteArr);                                                  //<----------------------------------------------------------
            var str:String = b64En.flush();                                                        //<----------------------------------------------------------
            trace(str.length);
            b64En.reset();
            trace("------------------------------------      " + str + "     -----------------------------");
            imageData.Base64EncodedImage = str;
            imageData.FileName = "nameofstring";
            imgService.UploadImage(imageData);
           imgService.addEventListener(FaultEvent.FAULT, servFault);
           imgService.addEventListener(ResultEvent.RESULT, imgServSuccess);
        public function imgServSuccess(event:ResultEvent):void{
            Alert.show("i am in the result");
            returnMsg = event.result as ReturnMessage;
            var resultStr:String = event.result as String;
            Alert.show(resultStr);
            if(returnMsg.ThereWasAnError){
                trace(returnMsg.ErrorMessages.getItemAt(0).toString());
        public function servFault(event:FaultEvent):void{
            Alert.show("2 " + event.fault.message);
            Alert.show("3 " + event.fault.faultCode);
    any help will be greatly appretiated!! thanks in advace!

    yeah i did actually... except i think i changed a LOT of code since i last posted this article...
    so i dont remember where this code is exactly... lol
    i have the following code now...
    hope this helps
    i use a a lot of webservices... so there is some of that code included in there aswell...
    * This file will do the file upload. It has been suggested to me multiple times, that using a queueing system for
    * file upload is not a good idea. Instead I declared a counter and used the final function to fire the next item
    * in the array. this also makes canceling a routine easier.
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.net.FileReference;
    import flash.net.FileReferenceList;
    import flash.utils.ByteArray;
    import mx.collections.ArrayCollection;
    import mx.controls.*;
    import mx.managers.*;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.utils.Base64Decoder;
    import mx.utils.Base64Encoder;
    import services.images.Images;
    import valueObjects.*;
        public var t:Number = 0;
        public var fileRef:FileReferenceList = new FileReferenceList();
        public var listCacheFiles:Array = new Array();
        [Bindable] public var fileListArr:Array = new Array();
        [Bindable] public var fileNames:ArrayCollection = new ArrayCollection();
        [Bindable] public var arrUploadFiles:Array = new Array();
        public var file:FileReference;
        public var _numCurrentUpload:Number = 0;
        public var imageData:valueObjects.ImageData;
        public var imageService:Images = new Images();
        public var saveImages:Images;
        public var returnMsg:ReturnMessage = new ReturnMessage();
        public var dataToSave:ImageData;
        public var myCounter:int = 0;
        public var numPerc:Number;
        /*vars to possible delete*/
        public var fileListx:ArrayCollection;
         * Initiates the browse, when files are selected the selectionHandler function is called
        public function initiateBrowse():void{
            var filter:Array = [];
            filter.push(new FileFilter("Images", ".gif;*.jepg;*.jpg;*.png"));
            fileRef.addEventListener(Event.SELECT, selectionHandler);
            fileRef.browse(filter);
         * selection handler takes the selected files and puts them in 2 different arrays
         * fileListArr contains all the file information like the image itself and the name and everything
         * fileNames contains the information essential to populate the datagrid in the cropper.mxml
        public function selectionHandler(event:Event):void{
            //trace("selection Handler ->>");
            fileRef.removeEventListener(Event.SELECT, selectionHandler);
            var numSelected:int = event.target.fileList.length;
            var fileList:Array = event.target.fileList;
            fileListx = new ArrayCollection();
            fileListx = event.target.fileList as ArrayCollection;
            //var oldListLength:Number = fileListArr.length;
            for each(var item:Object in fileList){
                fileListArr.push(item);
                fileNames.addItem({
                    num: fileNames.length + 1,
                    name: item.name,
                    size: formatFileSize(item.size),
                    status: "",
                    itemDetails: item
            var newListLength:Number = fileListArr.length;
            if(myCounter > 0)
                loopList(myCounter);
            else
                loopList(0);
         * this function starts one, new filereference for each files in the array
        public function loopList(value:int):void{
            //trace("looplist -->");
            if(value < fileListArr.length){
                _numCurrentUpload = value;       
                file = new FileReference();
                file = FileReference(fileListArr[value]);;
                file.addEventListener(Event.COMPLETE, loadImage);
                file.addEventListener(ProgressEvent.PROGRESS, fileProgress);
                file.load();
         * This function will convert the byte array into a string, and then it sends it to the server.
        public function loadImage(event:Event):void{
            trace("loadImage -->");
            file.removeEventListener(Event.COMPLETE, loadImage);
                myCounter += 1;
                var fileByteArr:ByteArray = event.target.data;
                var b64En:Base64Encoder = new Base64Encoder();
                b64En.encodeBytes(fileByteArr);
                var str:String = b64En.flush();
                imageData = new ImageData();
                imageData.Base64EncodedImage = str;
                imageData.FileName = event.target.name;
                trace("sending -->>  " + imageData.FileName);
                updateStatus("Sending to server");
                imageService.addEventListener(ResultEvent.RESULT, imgServSuccess);
                imageService.UploadImage(imageData);
                b64En.reset();
         * This function will decode the information recieved back from the server.
        public function imgServSuccess(event:ResultEvent):void{
            trace("imgServSuccess -->");
            imageService.removeEventListener(ResultEvent.RESULT, imgServSuccess);
            var returnedImageId:ArrayCollection = new ArrayCollection();
            returnMsg = event.result as ReturnMessage;
            var returnedData:Object = event.result.Images;
            var imgD:ImageData = new ImageData();
            if(returnMsg.ThereWasAnError){
                trace(returnMsg.ErrorMessages.getItemAt(0).toString());
            else{
                for each(var imgData:ImageData in returnedData){
                    var decoded:Base64Decoder = new Base64Decoder();
                    decoded.decode(imgData.Base64EncodedImage);
                    var byteArr:ByteArray = decoded.toByteArray();
                    //img.source = byteArr;
                dataToSave = new ImageData();
                dataToSave = returnedData[0];
                listCacheFiles.push(dataToSave);
                updateStatus("Item in Cache");
                //uploadDetails.visible = true;
                loopList(myCounter);
        public var win:itemDetails;
        public function itemClicking(event:Event):void{
            var fileName:String = event.currentTarget.dataProvider[0].name;
            for(var i:Number = 0; i < listCacheFiles.length; i++){
            //var temp:ImageData = event.target as ImageData;
            win = null;
            win = itemDetails(PopUpManager.createPopUp(this, itemDetails, true));
            win.title = "Enter Details";
            PopUpManager.centerPopUp(win);
            win["save"].addEventListener("click", popupClosed);
        public function popupClosed(event:Event):void{
            var returnedData:ImageData = new ImageData;
            returnedData = win.dataToSave;
            saveImgAndData(returnedData);
        public function saveImgAndData(data:ImageData):void{
            saveImages = new Images;
            saveImages.showBusyCursor = true;
            saveImages.addEventListener(ResultEvent.RESULT, savedSuccess);
            saveImages.addEventListener(FaultEvent.FAULT, faultFunc);
            saveImages.SaveUploadedImageInformation(data);
        public function faultFunc(event:FaultEvent):void{
            Alert.show(event.fault.message);
            Alert.show(event.fault.faultString);
        public function savedSuccess(event:ResultEvent):void{
            //trace("savedSuccess -->");
            var retMsg:Object = event.result.Images;
            //trace("saving -->> " + retMsg[0].FileName);
            updateStatus("Completed");
            //loopList(myCounter);
        private function formatFileSize(numSize:Number):String {
            var strReturn:String;
            numSize = Number(numSize / 1024);
            strReturn = String(numSize.toFixed(1) + " KB");
            if (numSize > 1024) {
                numSize = numSize / 1024;
                strReturn = String(numSize.toFixed(1) + " MB");
                if (numSize > 1024) {
                    numSize = numSize / 1024;
                    strReturn = String(numSize.toFixed(1) + " GB");
            return strReturn;
        public function removeFiles():void{
            var arrSelected:Array = displayFilesList.selectedIndices;
            if(arrSelected.length >= 1){
                for(var i:Number = 0; i < arrSelected.length; i++){
                    fileNames[Number(arrSelected[i])] = null;
                var idx:int = 1;
                for(var j:Number = 0; j < fileNames.length; j++){
                    if(fileNames[j] == null){
                        fileNames.removeItemAt(j);
                        j--;
                    }else{
                        fileNames[j].num = idx++;
                if(fileNames.length > 0)
                    displayFilesList.selectedIndex = 0;
                else
                    displayFilesList.selectedIndex = -1;
                _numCurrentUpload--;
                updateProgBar();
        private function updateStatus(status:String, index:Number = -1):void{
            index = _numCurrentUpload;
            fileNames[index].status = status;
            displayFilesList.invalidateList();
        public function fileProgress(event:ProgressEvent):void{
            //trace("fileProgress -->");
            var numPerc:Number = Math.round((Number(event.bytesLoaded) / Number(event.bytesTotal)) * 100);
            updateStatus("Uploading: " + numPerc.toString() + "%");
            updateProgBar(numPerc);
            var evt:ProgressEvent = new ProgressEvent("uploadProgress", false, false, event.bytesLoaded, event.bytesTotal);
            dispatchEvent(evt);
        public function updateProgBar(numPerc:Number = 0):void{
            //trace("updateProgBar -->");
            var strLabel:String = (_numCurrentUpload + 1) + "/" + fileNames.length;
            progBar.label = strLabel;
            progBar.setProgress(_numCurrentUpload + numPerc / 100, fileNames.length);
            progBar.validateNow();

Maybe you are looking for

  • Want to upgrade to 4G, but can't back up 3G

    I have an iphone 3G. I've tried numerous times to update the software from its current 3.1.2 to 4.2.1. I plug it in to the computer, itunes tells me I need to update the software, and then when I tell it to do so, I'm warned to transfer some purchase

  • Too many Subscribers/Receivers for Queue

    The link of Feedback in Java EE 5 tutorial doesn't work, because of this I ask my question here. I have tried the " Simple Example of Synchronous Message Receives" in Chapter 32 of Java EE 5 tutorial. In case of destination type queue I got error mes

  • Possible to decode an IRIG-B timestamp with NI-6601 (cross-posted on LabVIEW)

    We are preparing for a test that requires both time-varying data and quasi-steady data to be recorded and coordinated with a sort of timestamp. We can feed the IRIG signal into one of our NI-4472  channels in one DAQ system, but we need to coordinate

  • Resume after suspend-to-ram not working whit catalyst

    $uname -a Linux drog-laptop 3.4.6-1-ARCH #1 SMP PREEMPT Fri Jul 20 08:21:26 CEST 2012 x86_64 GNU/Linux $ pacman -Qs catalyst catalyst-hook 12.6-3 catalyst-utils 12.6-1 lib32-catalyst-utils 12.6-1 /var/log/pm-suspend.log http://pastebin.com/kWMWKqBy g

  • Capture flashing command prompt window in SS 2014 setup

    Setup (application) does not go too far. Just a quick flash - I assume Command Prompt - then it terminates. There maybe an error message in the window. How do I capture it? Thanks. ***** SETUP.EXE XML FILE ****** <?xml version="1.0" encoding="utf-8"