error writing an bigger size object to file

Anonymous
timer Asked: Jul 4th, 2013
account_balance_wallet $5

Question Description

Hello all, i m getting error while writing object to a file. for smaller size object no error it works fine but larger size object it writes but later getting error. can anybody help in this regard?


private void mistreeActionPerformed(java.awt.event.ActionEvent evt) {   
// TODO add your handling code here:
//int ret = jc.showOpenDialog(this);
  //  if(ret == JFileChooser.APPROVE_OPTION)
  //  {
  try
  {
  File f = jc.getSelectedFile();
  if(f != null){
  String fname = f.getAbsolutePath();
  datasetfile.setText(fname);   
  String database = fname;
  // tree = new MISTree();
  //if(fname != null)
  misTreeConstruction(database, output, Misout,MISfile);
  }
  else
  JOptionPane.showMessageDialog(null, "Plz select a file first");
     //tree.backtotrans();
  //printStats();
   
  }catch(Exception ex) {
  JOptionPane.showMessageDialog(null, "Error in input file Plz select trasanction file");
  // ex.printStackTrace();
  return;
  }
  // }
   
}  


public void misTreeConstruction(String input, String output, String Misout,String MISIn)
       throws FileNotFoundException, IOException {
     // record start time
     startTimestamp = System.currentTimeMillis();
     
     transactionCount = 0;
     // (1) PREPROCESSING: Perform an initial database scan to determine the
     // MIS of each item
     
     // This map is used to count the support of each item
     // Key: item  Value: support
mapSupport = new HashMap<Integer, Integer>();
mapSup = new HashMap<Integer, Integer>();
     // az---initializing MISs--------------
  //  writer1 = new BufferedWriter(new FileWriter(MISIn));
  calcMIS(input,Misout);
  initMISfromFile(MISIn);

     // reset the number of frequent itemsets to 0
     itemsetCount = 0;
     
     // create the object for writing the output file
     writer = new BufferedWriter(new FileWriter(output));

     // (2) Scan the database to build the initial FP-Tree
     // Before inserting a transaction in the FPTree, we sort the items
     // by decreasing order of MIS.
   tree = new MISTree();

     BufferedReader reader = new BufferedReader(new FileReader(input));
     String line;
     // read the transaction database line (transaction) by line
     // until the end of file
     while (((line = reader.readLine()) != null)) {
       // split the current transaction into items (they are separated by spaces)
       String[] lineSplited = line.split(" ");
       List<Integer> transaction = new ArrayList<Integer>();
       
       // for each item in the transaction
       for (String itemString : lineSplited) {
         // convert item to integer
         Integer item = Integer.parseInt(itemString);
         
         // increase the support of the item by 1
         Integer count = mapSupport.get(item);
         if (count == null) {
           mapSupport.put(item, 1);
  mapSup.put(item, 1);
         } else {
           mapSupport.put(item, ++count);
  mapSup.put(item, count);
         }
         // all items are added to transactions
         transaction.add(item);
       }
       transactionCount++; // increase the number of transactions
       
       // sort item in the transaction by non increasing order of MIS
       Collections.sort(transaction, this.itemComparator);
       
       // add the sorted transaction to the MISTree.
       tree.addTransaction(transaction);
       
     }// while
     reader.close();  // close the input file
     //writetologinred("Displaying tree");
   
  txt_area.setText("Displaying tree"+"\n");
   
     tree.print(tree.root, txt_area);

     // We create the header table for the tree
     tree.createHeaderList(this.itemComparator);
   
   
   
   
  //here
   
   
   
  try{
  JOptionPane.showMessageDialog(null,"in try");
     FileOutputStream fout = new FileOutputStream("d://obj.ser");
  JOptionPane.showMessageDialog(null,"obj created");
     ObjectOutputStream foos = new ObjectOutputStream(fout);  
  JOptionPane.showMessageDialog(null,"oos created");  ///til here i get output later getting error
     foos.writeObject(tree);
  JOptionPane.showMessageDialog(null,"here compltes writeobj");
  foos.flush();
  JOptionPane.showMessageDialog(null,"after flush");
     //foos.close();
  fout.close();
  JOptionPane.showMessageDialog(null,"alll");
     System.out.println("Done");
 
    }catch(Exception ex){
      JOptionPane.showMessageDialog(null,"error");
    }
   
   
   
  //here
   
   
   
  //frqpat.setEnabled(true);
  }

error is like this

Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError

  at java.lang.Exception.<init>(Unknown Source)

  at java.lang.reflect.InvocationTargetException.<init>(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)

  at java.io.ObjectOutputStream.writeObject(Unknown Source)

  at java.util.ArrayList.writeObject(Unknown Source)

  at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

  at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

  at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

  at java.io.ObjectOutputStream.writeObject0(Unknown Source)


Tutor Answer

jomar102693
School: UCLA

http://msdn.microsoft.com/en-us/library/windows/desktop/aa366542(v=vs.85).aspx

http://www.aspupload.com/manual_simple.html

flag Report DMCA
Review

Anonymous
Top quality work from this guy! I'll be back!

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors