Problem with ArrayLists and writing and reading from a .dat file (I think)

I'm brand new to this forum, but I'm sure hoping someone can help me with a problem I'm having with ArrayLists. This program was originally created with an array of objects that were displayed on a GUI with jtextFields, then cycling thru them via jButtons: First, Next, Previous, Last. Now I need to add the ability to modify, delete and add records. Both iterations of this program needed to write to and read from a .dat file.
It worked just like it was suppose to when I used just the array, but now I need to use a "dynamic array" that will grow or shrink as needed: i.e. an ArrayList.
When I aded the ArrayList I had the ArrayList use toArray() to fill my original array so I could continue to use all the methods I'd created for using with my array. Now I'm getting a nullPointerException every time I try to run my program, which means somewhere I'm NOT filling my array ???? But, I'm writing just fine to my .dat file, which is confusing me to no end!
It's a long program, and I apologize for the length, but here it is. There are also 2 class files, a parent and 1 child below Inventory6. This was written in NetBeans IDE 5.5.1.
Thank you in advance for any help anyone can give me!
LabyBC
package my.Inventory6;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.lang.IllegalStateException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.text.NumberFormat;
// Class Inventory6
public class Inventory6 extends javax.swing.JFrame {
private static InventoryPlusColor[] inventory;
private static ArrayList inList;
// create a tool that insure the specified format for a double number, when displayed
private DecimalFormat doubleFormat = new DecimalFormat( "0.00" );
private DecimalFormat singleFormat = new DecimalFormat( "0");
// the index within the array of products of the current displayed product
private int currentProductIndex;
/** Creates new form Inventory6 */
public Inventory6() {
initComponents();
currentProductIndex = 0;
} // end Inventory6()
private static InventoryPlusColor[] getInventory() {
ArrayList<InventoryPlusColor> inList = new ArrayList<InventoryPlusColor>();
inList.add(new InventoryPlusColor(1, "Couch", 3, 1250.00, "Blue"));
inList.add(new InventoryPlusColor(2, "Recliner", 10, 525.00, "Green"));
inList.add(new InventoryPlusColor(3, "Chair", 6, 125.00, "Mahogany"));
inList.add(new InventoryPlusColor(4, "Pedestal Table", 2, 4598.00, "Oak"));
inList.add(new InventoryPlusColor(5, "Sleeper Sofa", 4, 850.00, "Yellow"));
inList.add(new InventoryPlusColor(6, "Rocking Chair", 2, 459.00, "Tweed"));
inList.add(new InventoryPlusColor(7, "Couch", 4, 990.00, "Red"));
inList.add(new InventoryPlusColor(8, "Chair", 12, 54.00, "Pine"));
inList.add(new InventoryPlusColor(9, "Ottoman", 3, 110.00, "Black"));
inList.add(new InventoryPlusColor(10, "Chest of Drawers", 5, 598.00, "White"));
for (int j = 0; j < inList.size(); j++)
System.out.println(inList);
InventoryPlusColor[] inventory = (InventoryPlusColor[]) inList.toArray
(new InventoryPlusColor[inList.size()]);
return inventory;
} // end getInventory() method
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
IDNumberLbl = new javax.swing.JLabel();
IDNumberField = new javax.swing.JTextField();
prodNameLbl = new javax.swing.JLabel();
prodNameField = new javax.swing.JTextField();
colorLbl = new javax.swing.JLabel();
colorField = new javax.swing.JTextField();
unitsInStockLbl = new javax.swing.JLabel();
unitsInStockField = new javax.swing.JTextField();
unitPriceLbl = new javax.swing.JLabel();
unitPriceField = new javax.swing.JTextField();
invenValueLbl = new javax.swing.JLabel();
invenValueField = new javax.swing.JTextField();
restockingFeeLbl = new javax.swing.JLabel();
restockingFeeField = new javax.swing.JTextField();
jbtFirst = new javax.swing.JButton();
jbtNext = new javax.swing.JButton();
jbtPrevious = new javax.swing.JButton();
jbtLast = new javax.swing.JButton();
jbtAdd = new javax.swing.JButton();
jbtDelete = new javax.swing.JButton();
jbtModify = new javax.swing.JButton();
jbtSave = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
searchIDNumLbl = new javax.swing.JLabel();
searchIDNumbField = new javax.swing.JTextField();
jbtSearch = new javax.swing.JButton();
searchResults = new javax.swing.JLabel();
jbtExit = new javax.swing.JButton();
jbtExitwoSave = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Inventory Program"));
IDNumberLbl.setText("ID Number");
IDNumberField.setEditable(false);
prodNameLbl.setText("Product Name");
prodNameField.setEditable(false);
colorLbl.setText("Product Color");
colorField.setEditable(false);
colorField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
colorFieldActionPerformed(evt);
unitsInStockLbl.setText("Units In Stock");
unitsInStockField.setEditable(false);
unitPriceLbl.setText("Unit Price $");
unitPriceField.setEditable(false);
invenValueLbl.setText("Inventory Value $");
invenValueField.setEditable(false);
restockingFeeLbl.setText("5% Restocking Fee $");
restockingFeeField.setEditable(false);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(unitPriceLbl)
.addComponent(unitsInStockLbl)
.addComponent(colorLbl)
.addComponent(prodNameLbl)
.addComponent(IDNumberLbl)
.addComponent(restockingFeeLbl)
.addComponent(invenValueLbl))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(IDNumberField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
.addComponent(prodNameField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
.addComponent(colorField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
.addComponent(unitsInStockField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
.addComponent(unitPriceField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
.addComponent(restockingFeeField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
.addComponent(invenValueField, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE))
.addContainerGap())
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(IDNumberLbl)
.addComponent(IDNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(prodNameLbl)
.addComponent(prodNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(colorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(colorLbl))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(unitsInStockField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(unitsInStockLbl))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(unitPriceField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(unitPriceLbl))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(restockingFeeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(restockingFeeLbl))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(invenValueField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(invenValueLbl))
.addContainerGap())
jbtFirst.setText("First");
jbtFirst.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtFirstActionPerformed(evt);
jbtNext.setText("Next");
jbtNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtNextActionPerformed(evt);
jbtPrevious.setText("Previous");
jbtPrevious.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtPreviousActionPerformed(evt);
jbtLast.setText("Last");
jbtLast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtLastActionPerformed(evt);
jbtAdd.setText("Add");
jbtAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtAddActionPerformed(evt);
jbtDelete.setText("Delete");
jbtModify.setText("Modify");
jbtModify.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtModifyActionPerformed(evt);
jbtSave.setText("Save");
jbtSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtSaveActionPerformed(evt);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Search by:"));
searchIDNumLbl.setText("Item Number:");
jbtSearch.setText("Search");
searchResults.setFont(new java.awt.Font("Tahoma", 1, 12));
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(searchIDNumLbl)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(259, 259, 259)
.addComponent(searchResults, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jbtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(searchIDNumbField, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(searchIDNumLbl)
.addComponent(searchIDNumbField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(searchResults, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtSearch)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
jbtExit.setText("Save and Exit");
jbtExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtExitActionPerformed(evt);
jbtExitwoSave.setText("Exit");
jbtExitwoSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtExitwoSaveActionPerformed(evt);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jbtExitwoSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jbtExit)))
.addGroup(layout.createSequentialGroup()
.addComponent(jbtFirst)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtNext)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtPrevious)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtLast))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jbtAdd)
.addComponent(jbtDelete)
.addComponent(jbtModify)
.addComponent(jbtSave))))
.addContainerGap())
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbtFirst, jbtLast, jbtNext, jbtPrevious});
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbtAdd, jbtDelete, jbtModify, jbtSave});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jbtAdd)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtDelete)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtModify)
.addGap(39, 39, 39)
.addComponent(jbtSave))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jbtFirst)
.addComponent(jbtNext)
.addComponent(jbtPrevious)
.addComponent(jbtLast))
.addGap(15, 15, 15)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jbtExit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtExitwoSave)))
.addContainerGap())
pack();
}// </editor-fold>
private void jbtExitwoSaveActionPerformed(java.awt.event.ActionEvent evt) {                                             
System.exit(0);
private void jbtSaveActionPerformed(java.awt.event.ActionEvent evt) {                                       
String prodNameMod, colorMod;
double unitsInStockMod, unitPriceMod;
int idNumMod;
idNumMod = Integer.parseInt(IDNumberField.getText());
prodNameMod = prodNameField.getText();
unitsInStockMod = Double.parseDouble(unitsInStockField.getText());
unitPriceMod = Double.parseDouble(unitPriceField.getText());
colorMod = colorField.getText();
if(currentProductIndex == inventory.length) {
inList.add(new InventoryPlusColor(idNumMod, prodNameMod,
unitsInStockMod, unitPriceMod, colorMod));
InventoryPlusColor[] inventory = (InventoryPlusColor[]) inList.toArray
(new InventoryPlusColor[inList.size()]);
} else {
inventory[currentProductIndex].setIDNumber(idNumMod);
inventory[currentProductIndex].setProdName(prodNameMod);
inventory[currentProductIndex].setUnitsInStock(unitsInStockMod);
inventory[currentProductIndex].setUnitPrice(unitPriceMod);
inventory[currentProductIndex].setColor(colorMod);
displayProduct(inventory[currentProductIndex]);
private static void writeInventory(InventoryPlusColor i,
DataOutputStream out) {
try {
out.writeInt(i.getIDNumber());
out.writeUTF(i.getProdName());
out.writeDouble(i.getUnitsInStock());
out.writeDouble(i.getUnitPrice());
out.writeUTF(i.getColor());
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "I/O Exception writing data",
"", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} //end writeInventory()
private static DataOutputStream openOutputStream(String name) {
DataOutputStream out = null;
try {
File file = new File(name);
out =
new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream(file)));
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "I/O Error", "", JOptionPane.ERROR_MESSAGE);
System.exit(0);
return out;
} // end openOutputStream()
private static void closeFile(DataOutputStream out) {
try {
out.close();
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "I/O Exception closing file",
"", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} // end closeFile()
private static DataInputStream getStream(String name) {
DataInputStream in = null;
try {
File file = new File(name);
in = new DataInputStream(
new BufferedInputStream(
new FileInputStream(file)));
} catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(null, "The file doesn't exist",
"", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "I/O Error creating file",
"", JOptionPane.ERROR_MESSAGE);
System.exit(0);
return in;
private static void closeInputFile(DataInputStream in) {
try {
in.close();
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "I/O Exception closing file",
"", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} // end closeInputFile()
private double entireInventory() {
// a temporary double variable that the method will return ...
// after each product's inventory is added to it
double entireInventory = 0;
// loop to control number of products
for (int index = 0; index < inventory.length; index++) {
// add each inventory to the entire inventory
entireInventory += inventory[index].setInventoryValue();
} // end loop to control number of products
return entireInventory;
} // end method entireInventory
private void jbtLastActionPerformed(java.awt.event.ActionEvent evt) {                                       
currentProductIndex = inventory.length-1; // move to the last product
// display the information for the last product
displayProduct(inventory[currentProductIndex]);
private void jbtPreviousActionPerformed(java.awt.event.ActionEvent evt) {                                           
if (currentProductIndex != 0) // it's not the first product displayed
currentProductIndex -- ; // move to the previous product (decrement the current index)
} else // the first product is displayed
currentProductIndex = inventory.length-1; // move to the last product
// after the current product index is set, display the information for that product
displayProduct(inventory[currentProductIndex]);
private void jbtNextActionPerformed(java.awt.event.ActionEvent evt) {                                       
if (currentProductIndex != inventory.length-1) // it's not the last product displayed
currentProductIndex ++ ; // move to the next product (increment the current index)
} else // the last product is displayed
currentProductIndex = 0; // move to the first product
// after the current product index is set, display the information for that product
displayProduct(inventory[currentProductIndex]);
private void jbtFirstActionPerformed(java.awt.event.ActionEvent evt) {                                        
currentProductIndex = 0;
// display the information for the first product
displayProduct(inventory[currentProductIndex]);
private void colorFieldActionPerformed(java.awt.event.ActionEvent evt) {                                          
// TODO add your handling code here:
private void jbtModifyActionPerformed(java.awt.event.ActionEvent evt) {                                         
prodNameField.setEditable(true);
prodNameField.setFocusable(true);
unitsInStockField.setEditable(true);
unitPriceField.setEditable(true);
private void jbtAddActionPerformed(java.awt.event.ActionEvent evt) {                                      
IDNumberField.setText("");
IDNumberField.setEditable(true);
prodNameField.setText("");
prodNameField.setEditable(true);
colorField.setText("");
colorField.setEditable(true);
unitsInStockField.setText("");
unitsInStockField.setEditable(true);
unitPriceField.setText("");
unitPriceField.setEditable(true);
restockingFeeField.setText("");
invenValueField.setText("");
currentProductIndex = inventory.length;
private void jbtExitActionPerformed(java.awt.event.ActionEvent evt) {                                       
DataOutputStream out = openOutputStream("inventory.dat");
for (InventoryPlusColor i : inventory)
writeInventory(i, out);
closeFile(out);
System.exit(0);
private static InventoryPlusColor readProduct(DataInputStream in) {
int idNum = 0;
String prodName = "";
double inStock = 0.0;
double pric

BalusC -- The line that gives me my NullPointerException is when I call the "DisplayProduct()" method. Its a dumb question, but with NetBeans how do I find out which reference could be null? I'm not very familiar with how NetBeans works with finding out how to debug. Any help you can give me would be greatly appreciated.The IDE is com-plete-ly irrelevant. It's all about the source code.
Do you understand anyway when and why a NullPointerException is been thrown? It is a subclass of RuntimeException and those kind of exceptions are very trival and generally indicate an design/logic/thinking fault in your code.
SomeObject someObject = null; // The someObject reference is null.
someObject.doSomething(); // Invoking a reference which is null would throw NPE.

Similar Messages

  • Problem with exporting and printing from pages to PDF

    I have a problem with my Pages
    My font will not be embeded in my pdf files.
    I have saved as a ps file and in to the destiller and my fonts are missing.
    I need to send my file to the print shop but they will not accept my file and i now understand why.
    fonts are missing...
    Is there a workaround.
    I have no problem in Indesign or quark but pages.....
    I need help
    thanks a zillion

    The font is coming from a notation software Sibelius 4 and is namned opus
    Hmmm ... Sibelius is a music notation software and notations are marked up in MusicXML. Presumably the font file is an SFNT with TrueType splines, but it is probably not installed in OS X system folders - rather in an internal Sibelius application font folder. So presumably you do not see the font in FontBook and OS X font auditing does not apply to the font.
    Sibelius exports EPS files, right? If memory serves, an EPS is still legal even if the font resource is not embedded. And in any case, we know from the behaviour that the font resource is not embedded for some reason. So how do you get Sibelius to put the font resource inside the graphic ... normally there is a button in the EPS export procedure that gives you the option to Embed All Fonts.
    You do not seem to get this button, though. Or why else would you not have checked it already and the problem would have gone away already.
    The next point in troubleshooting this is that you are not following the path that would let OS X detect that an external font resource is not embedded.
    I go from pages-print-printer- acrobat Pro 8-save as Pdf-x
    What you are doing here is telling Pages to tell OS X to generate a PostScript program within which is nested your Encapsulated PostScript program with the call to an unresolved external font resource.
    So why does Acrobat Pro not detect the unresolved external font resource? Hmm ... did you try the Preflight option in Acrobat 8 Pro? It should provide information on unresolved embeddings.
    I have also tried pages-print-printer- acrobat Pro 8 and save pdf as postscript and put the postscript file in destiller 8 pro with defalt setting high quality print
    The whole problem with EPS and PS is that this sort of situation is possible in the first place (plus, what is worse, the PS program can include custom additions to the graphics model that then fail in the PS interpreter whence Apple GX normalizing, Adobe Distiller normalizing, and Apple Quartz normalizing). You want to get as far away from EPS and PS as possible, believe me.
    So, you have not done what I posted that you should do in the first place. If I were you, I would first get rid of the problem that the EPS is making a call to an external font and then get rid of the problem that the PostScript is preserving the external call.
    To get rid of the problem that the EPS is preserving an external call, simply open the EPS in Apple Preview which includes a NORMALIZER for EPS/PS, and then save out the graphic as PDF. Alternatively, if you don't trust Quartz for some reason, set up a hotfolder for Distiller, make sure the option to embed all fonts is enabled, and convert the EPS to PDF.
    Now replace your EPS in Pages with PDF in Pages, and don't save PostScript to disk but save PDF to disk through the proper procedure which is File > Print > PDF > Save as PDF/X [for your custom configuration of the PDF/X-3 filter considering that no sane person in North Europe prints lowend US SWOP, we use ISO].
    If you begin by telling OS X that you want PDF within which fonts are supposed to be embedded ALWAYS, then you have started the right way. Otherwise, you have not told the operating system what you want to do, and this then leads you into places where you are unlikely to have the expertise to troubleshoot problems.
    So, forget placing EPS in the first place, place PDF. And forget saving PostScript to disk, save PDF to disk. If that does not sort your problem, here is the dirty solution for professional prepress.
    Adobe Photoshop has an EPS rasterizer that has wide tolerances for poor PostScript programming (so does Adobe Illustrator 6 and higher by the way).
    Therefore, if an EPS is posing problems, one workaround is to rasterize the EPS at high resolution in Photoshop and place that high resolution PDF in your layout.
    Take care that you rasterize as 1 bit at the required resolution of the print provider, probably 2450 dpi. When you save the 1 bit as PDF, Photoshop automatically compresses to a very, very small file (don't be surprised if 15Mb compresses to something like 0.5Mb).
    Rasterizing in Photoshop should not be necessary if you simply start by telling the operating system what it is you are trying to do. Then the operating system should be able to take the right decisions for you, and tell if you if finds problems it cannot resolve without turning to you.
    Good luck,
    Henrik
    would-be technical writer

  • HOW TO WRITE AND READ FROM A TEXT FILE???

    How can I read from a text file and then display the contents in a JTextArea??????
    Also how can I write the contents of a JTextArea to a text file.
    Extra Question::::::: Is it possible to write records to a text file. If you have not idea what I am talking about then ignore it.
    Manny thanks,
    your help is much appreciated though you don't know it!

    Do 3 things.
    -- Look through the API at the java.io package.
    -- Search previous posts for "read write from text file"
    -- Search java.sun.com for information on the java.io package.
    That should clear just about everything up. If you have more specific problems, feel free to come back and post them.

  • How to read from 2 data files ?

    Hi,
    I'm trying to create a program that will read data from two dat files that are linked by a reference code in each file.
    I have been using StringTokenizer to read from one file as follows:
    but the problem is that the dat files contain int, String and double values.
    import java.io.*;
    import java.util.StringTokenizer;
    public class Student
         public static void main(String[]args)
         String file = "CourseWork.dat";//Locate the file to open
         String input;     // to be used to identify each line of text
         String word;     // used to identify each word in the text
         StringTokenizer tokenizer;//value of StringTokenizer
         BufferedReader fin = Text.open(file);
         input = fin.readLine;          
         while (input !=null)          
                   tokenizer = new StringTokenizer (input);
                   while (tokenizer.hasMoreTokens())                {                                                                                               word = tokenizer.nextToken();
                   System.out.println(input);
                   input = fin.readLine();
    Any pointers greatly appreciated

    read all of them to a StringBuffer,
    then stoken.
    peter
    Pivotonic Inc. http://www.pivotonic.com
    1. java IDE tool : JawaBeginer
    2. java jar tool : JavaJar
    -----------------------------

  • Having problem with adding and reading dates to/from database !!!

    Hi
    I am new in J2ME
    I am trying to code a simple software.
    My problem is with dates.
    I have a datefield on my menu and the user will choose the date from here. By default, datefield shows todays date. But when I try to write that date to database using rms, date value transforms to java.util.Date@acfdb0fe.
    As I read from tutorials this is common problem of date class, so I tried to use calendar class.
    But with Calendar class I cannot let user to choose date from screen like DateField. datefield dowsn't work with calendar.
    later, I will use that date for sorting records
    Summary : I need a sample code that read date from screen (preferably with datefield), write it to recordstore. and then read it from recordstore asnd write to screen.
    I searching internet for a sample code through days.
    Please help me
    Thanks

    Hi,
    The best i would suggest is instead of storing the date as 19 Jan 2004 or something like this better store the date in milliseconds.
    DateField df = new DateField();
    Date d = df.getDate();
    long ms = d.getTime();
    store the value of ms in RMS. This is the commonly used way to store date in RMS for j2me.
    You can get back date using
    Date d = new Date(ms);
    DateField df = new DateField();
    df.setDate(d);
    Prabhu.

  • Problem with BTE and FI-parking- no data from memory ID to ABAP

    Hi Experts,
    I have a scenario in Business Workflow where I want to catch the data(BKPF & BSEG) after SAP transaction processing - event is to change parked FI-document with FBV2. I´m trying to use BTE to receive the data after processing transaction.
    All BTE steps seems to be activated - because I can debug my functions when processing FBV2 - but I cannot reach any data into my coding after processing.
    I have created my project in BF24:
    ZXXX Testing: WF-memory ID
    I have also linked few FI-events to my BTE interface funtion in BF34:
    00001130 ZXXX ZXXX_FIPP_CHANGE_BTE
    00002213 ZXXX ZXXX_FIPP_CHANGE_BTE
    00002217 ZXXX ZXXX_FIPP_CHANGE_BTE
    My BTE function ZXXX_FIPP_CHANGE_BTE is as following:
    DATA: memid(15) VALUE 'ZXXX_2217'.
    *Initialize
    CLEAR: t_vbkpf,
    t_vbsegs.
    FREE MEMORY ID 'ZXXX_2217'.
    *Backtracking of BTE
    EXPORT t_vbkpf
    t_vbsegs
    TO MEMORY ID memid.
    ENDFUNCTION.
    I have also created funtion to call FBV2:
    data: memid(15) value 'ZXXX_2217'.
    CALL TRANSACTION 'FBV2'.
    *Import memory of BTE
    IMPORT t_vbkpf
    t_vbsegs
    FROM MEMORY ID memid.
    *Free memory id
    FREE MEMORY ID memid.  
    When I set a breakpoint to both of the functions and I execute FBV2 I reach the breakpoints. Problem is that the data is not passed from memid 'ZXXX_2217' into function after FBV2(this syntax: IMPORT t_vbkpf t_vbsegs FROM MEMORY ID memid.)
    What could be missing. So both functions are called but NO DATA is passed from memory ID to my internal tables? This seems to be a problem with memory ID´s. Also in my BTE function ZXXX_FIPP_CHANGE_BTE I receive a sy-subrc value 4 when executing syntax "FREE MEMORY ID 'ZXXX_2217'. ".
    All hints appreciated,
    Jani

    Hi Ramki,
    I must be frustrating You with these stupid questions... You have already supported me hugely to get more famailiar with BTE. For example not to commit in BTE etc. Big thanks for that!
    In all cases when I have tested my project in BF24 has been always active; and yes I have changed the pre. posted document always to trigger the BTE.
    I still have a problem. I copied all customizing and coding into other system - with same dissapointing results. Let me describe this once more:
    <b>My entry in BF24:</b>
    <i>Product:                 ZBE
    Text:                       Jani testing
    RFC destination:
    Active:   </i>               X
    <b>My entry in BF34:</b>
    <i>Event:                   00002214
    Product:                    ZBE
    Ctr:
    Appl:
    Function module:            ZBE_BTE</i>
    <b>My BTE function:</b>
    <i>  DATA: memid(15) VALUE 'ZBE_BTE2214'.
      DATA: t_vbkpf LIKE fvbkpf OCCURS 0 WITH HEADER LINE.
      FREE MEMORY ID memid.
      EXPORT t_vbkpf TO MEMORY ID memid.</i>
    <b>And the function ZBE_BTE_EXECUTE where I call FBV2:</b>
    <i>  DATA: memid(15) VALUE 'ZBE_BTE2214'.
      DATA: t_vbkpf LIKE fvbkpf OCCURS 0 WITH HEADER LINE.
      CALL TRANSACTION 'FBV2'.
      IMPORT t_vbkpf FROM MEMORY ID memid.
      FREE MEMORY ID memid.</i>
    When I process my function ZBE_BTE_EXECUTE - and I have added a breakpoint into ZBE_BTE - for FBV2 call <b>it does not reach the breakpoint</b> in ZBE_BTE at all! This occurs when using event linkage 00002214! And I do execute a real change to parked document.
    But if I change the entry in BF34 to be linked for event 00002217 or 00002218 process reaches my breakpoint in BTE function ZBE_BTE! But in these cases also, it does not import the data after transaction call in function ZBE_BTE_EXECUTE. When I continue debugging the coding in BTE function ZBE_BTE further into SAP-coding, I can see that my internal table t_vbkpf is filled. But when I leave SAP-coding when FBV2 is completed and return to ZBE_BTE_EXECUTE - where t_vbkpf should be filled from memory id - t_vbkpf is empty!
    Again as a conclusion in this system:
    For BTE event 00002214 this locig does not work at all. For events 00002217 and 00002218 it does get activated, but does not bring any data from memory ID into my abap. Strangest this is that I use absolutely same kind of coding that You.
    Can You see if I have to fill those empty fields( Ctr. & Appl.) in my BF34 customizing? Or is some other customizing action missing?
    Br,
    Jani

  • Upload problems with Facebook and Vimeo from Premiere Elements 10

    I have created a project in HD and am trying to upload to Vimeo.  Premiere Elements 10 does not have a preset so I followed some instructions from the Vimeo website.  Project is "blurry" when viewed.  I checked with Vimeo and they said what they converted matches what I sent so the problem must be in the export - bit rate may be incorrect.  Can anyone give me the correct presets for Vimeo from Premiere Elements 10.  I can view other people's video in HD and they look fine so I don't think it's my computer monitor.   I'm sure you will need more information about my project so please give me a list of specific things you need to know.  Thank you.
    My Facebook problem is as follows.  If I use the preset from Premiere Elements 10 to upload to Facebook it looks fine, HD quality as expected.  Problem is, I would like to upload to my business page.  Since the personal page and the business page (managed by my personal account) share a login, the preset always loads to my personal page.  Does anyone know the values of the preset so I can upload the video to my business page.  My business is event and wedding videography so I would like the posts to be as clear as possible.
    If the problem with the Vimeo uploads is solved then I suppose I can just share the Vimeo file on Facebook.  Thank you.

    VDRAVES
    I think that you are overlooking what you already have with regard to a Vimeo HD preset for export to file for upload of the saved file at the Vimeo website.
    Please see
    Share/Computer/AVCHD with Presets = Vimeo HD
    Under the Advanced Button/Video Tab, you can customize the preset further from 1280 x 720 to 1920 x 1080 and increase the bitrate, if necessary, to a level that does not give you a prohibitive file size. With Profile = Main and Level = 3.1, the bitrate range is 0.19 to 14 Mbps (megabits per second).
    I would start with the default bitrates of Target = 8 Mbps and Maximium = 9 Mbps and explore and experiment from there.
    If you customize the preset to 1920 x 1080 in the Export Settings customization area, then change the Profile to High and the Level to 5.1
    When you do that the bitrate range will be 0.19 to 300 Mbps instead of 0.19 to 14 Mbps.
    In all cases, watch for file size versus bitrate versus quality of end product.
    Please give that a look and then let us know if the above resolves your Vimeo and Facebook question.
    Please review and let us know the outcome.
    Thank you.
    ATR

  • Performance problems with XMLTABLE and XMLQUERY involving relational data

    Hello-
    Is anyone out there using XMLTABLE or XMLQUERY with more than a toy set of data? I am running into serious performance problems tyring to do basic things such as:
    * Combine records in 10 relational tables into a single table of XMLTYPE records using XMLTABLE. This hangs indefinitely for any more than 800 records. Oracle has confirmed that this is a problem and is working on a fix.
    * Combine a single XMLTYPE record with several relational code tables into a single XMLTYPE record using XMLQUERY and ora:view() to insert code descriptions after each code. Performance is 10 seconds for 10 records (terrible) passing a batch of records , or 160 seconds for one record (unacceptable!). How can it take 10 times longer to process 1/10th the number of records? Ironically, the query plan says it will do a full table scan of records for the batch, but an index access for the one record passed to the XMLQUERY.
    I am rapidly losing faith in XML DB, and desparately need some hints on how to work around these performance problems, or at least some assurance that others have been able to get this thing to perform.

    <Note>Long post, sorry.</Note>
    First, thanks for the responses above. I'm impressed with the quality of thought put into them. (Do the forum rules allow me to offer rewards? :) One suggestion in particular made a big performance improvement, and I’m encouraged to hear of good performance in pure XML situations. Unfortunately, I think there is a real performance challenge in two use cases that are pertinent to the XML+relational subject of this post and probably increasingly common as XML DB usage increases:
    •     Converting legacy tabular data into XML records; and
    •     Performing code table lookups for coded values in XML records.
    There are three things I want to accomplish with this post:
    •     Clarify what we are trying to accomplish, which might expose completely different approaches than I have tried
    •     Let you know what I tried so far and the rationale for my approach to help expose flaws in my thinking and share what I have learned
    •     Highlight remaining performance issues in hopes that we can solve them
    What we are trying to accomplish:
    •     Receive a monthly feed of 10,000 XML records (batched together in text files), each containing information about an employee, including elements that repeat for every year of service. We may need to process an annual feed of 1,000,000 XML records in the future.
    •     Receive a one-time feed of 500,000 employee records stored in about 10 relational tables, with a maximum join depth of 2 or 3. This is inherently a relational-to-XML process. One record/second is minimally acceptable, but 10 records/sec would be better.
    •     Consolidate a few records (from different providers) for each employee into a single record. Given the data volume, we need to achieve a minimum rate of 10 records per second. This may be an XML-only process, or XML+relational if code lookups are done during consolidation.
    •     Allow the records to be viewed and edited, with codes resolved into user-friendly descriptions. Since a user is sitting there, code lookups done when a record is viewed (vs. during consolidation) should not take more than 3 seconds total. We have about 20 code tables averaging a few hundred rows each, though one has 450,000 rows.
    As requested earlier, I have included code at the end of this post for example tables and queries that accurately (but simply) replicate our real system.
    Why we did and why:
    •     Stored the source XML records as CLOBS: We did this to preserve the records exactly as they were certified and sent from providers. In addition, we always access the entire XML record as a whole (e.g., when viewing a record or consolidating employee records), so this storage model seemed like a good fit. We can copy them into another format if necessary.
    •     Stored the consolidated XML employee records as “binary XML”. We did this because we almost always access a single, entire record as a whole (for view/edit), but might want to create some summary statistics at some point. Binary XML seemed the best fit.
    •     Used ora:view() for both tabular source records and lookup tables. We are not aware of any alternatives at this time. If it made sense, most code tables could be pre-converted into XML documents, but this seemed risky from a performance standpoint because the lookups use both code and date range constraints (the meaning of codes changes over time).
    •     Stored records as XMLTYPE columns in a table with other key columns on the table, plus an XMLTYPE metadata column. We thought this would facilitate pulling a single record (or a few records for a given employee) quickly. We knew this might be unnecessary given XML indexes and virtual columns, but were not experienced with those and wanted the comfort of traditional keys. We did not used XMLTYPE tables or the XML Repository for documents.
    •     Used XMLTABLE to consolidate XML records by looping over each distinct employee ID in the source batch. We also tried XMLQUERY and it seems to perform about the same. We can achieve 10 to 20 records/second if we do not do any code lookups during consolidation, just meeting our performance requirement, but still much slower than expected.
    •     Used PL/SQL with XMLFOREST to convert tabular source records to XML by looping over distinct employee IDs. We tried this outside PL/SQL both with XMLFOREST and XMLTABLE+ora:view(), but it hangs in both cases for more than 800 records (a known/open issue). We were able to get it to work by using an explicit cursor to loop over distinct employee IDs (rather than processing all records at once within the query). The performance is one record/second, which is minimally acceptable and interferes with other database activity.
    •     Used XMLQUERY plus ora:view() plus XPATH constraints to perform code lookups. When passing a single employee record, the response time ranges from 1 sec to 160 sec depending on the length of the record (i.e., number of years of service). We achieved a 5-fold speedup using an XMLINDEX (thank you Marco!!). The result may be minimally acceptable, but I’m baffled why the index would be needed when processing a single XML record. Other things we tried: joining code tables in the FOR...WHERE clauses, joining code tables using LET with XPATH constraints and LET with WHERE clause constraints, and looking up codes individually via JDBC from the application code at presentation time. All those approaches were slower. Note: the difference I mentioned above in equality/inequality constraint performance was due to data record variations not query plan variations.
    What issues remain?
    We have a minimally acceptable solution from a performance standpoint with one very awkward PL/SQL workaround. The performance of a mixed XML+relational data query is still marginal IMHO, until we properly utilize available optimizations, fix known problems, and perhaps get some new query optimizations. On the last point, I think the query plan for tabular lookups of codes in XML records is falling short right now. I’m reminded of data warehousing in the days before hash joins and star join optimization. I would be happy to be wrong, and just as happy for viable workarounds if I am right!
    Here are the details on our code lookup challenge. Additional suggestions would be greatly appreciated. I’ll try to post more detail on the legacy table conversion challenge later.
    -- The main record table:
    create table RECORDS (
    SSN varchar2(20),
    XMLREC sys.xmltype
    xmltype column XMLREC store as binary xml;
    create index records_ssn on records(ssn);
    -- A dozen code tables represented by one like this:
    create table CODES (
    CODE varchar2(4),
    DESCRIPTION varchar2(500)
    create index codes_code on codes(code);
    -- Some XML records with coded values (the real records are much more complex of course):
    -- I think this took about a minute or two
    DECLARE
    ssn varchar2(20);
    xmlrec xmltype;
    i integer;
    BEGIN
    xmlrec := xmltype('<?xml version="1.0"?>
    <Root>
    <Id>123456789</Id>
    <Element>
    <Subelement1><Code>11</Code></Subelement1>
    <Subelement2><Code>21</Code></Subelement2>
    <Subelement3><Code>31</Code></Subelement3>
    </Element>
    <Element>
    <Subelement1><Code>11</Code></Subelement1>
    <Subelement2><Code>21</Code></Subelement2>
    <Subelement3><Code>31</Code></Subelement3>
    </Element>
    <Element>
    <Subelement1><Code>11</Code></Subelement1>
    <Subelement2><Code>21</Code></Subelement2>
    <Subelement3><Code>31</Code></Subelement3>
    </Element>
    </Root>
    for i IN 1..100000 loop
    insert into records(ssn, xmlrec) values (i, xmlrec);
    end loop;
    commit;
    END;
    -- Some code data like this (ignoring date ranges on codes):
    DECLARE
    description varchar2(100);
    i integer;
    BEGIN
    description := 'This is the code description ';
    for i IN 1..3000 loop
    insert into codes(code, description) values (to_char(i), description);
    end loop;
    commit;
    end;
    -- Retrieve one record while performing code lookups. Takes about 5-6 seconds...pretty slow.
    -- Each additional lookup (times 3 repeating elements in the data) adds about 1 second.
    -- A typical real record has 5 Elements and 20 Subelements, meaning more than 20 seconds to display the record
    -- Note we are accessing a single XML record based on SSN
    -- Note also we are reusing the one test code table multiple times for convenience of this test
    select xmlquery('
    for $r in Root
    return
    <Root>
    <Id>123456789</Id>
    {for $e in $r/Element
        return
        <Element>
          <Subelement1>
            {$e/Subelement1/Code}
    <Description>
    {ora:view("disaac","codes")/ROW[CODE=$e/Subelement1/Code]/DESCRIPTION/text() }
    </Description>
    </Subelement1>
    <Subelement2>
    {$e/Subelement2/Code}
    <Description>
    {ora:view("disaac","codes")/ROW[CODE=$e/Subelement2/Code]/DESCRIPTION/text()}
    </Description>
    </Subelement2>
    <Subelement3>
    {$e/Subelement3/Code}
    <Description>
    {ora:view("disaac","codes")/ROW[CODE=$e/Subelement3/Code]/DESCRIPTION/text() }
    </Description>
    </Subelement3>
    </Element>
    </Root>
    ' passing xmlrec returning content)
    from records
    where ssn = '10000';
    The plan shows the nested loop access that slows things down.
    By contrast, a functionally-similar SQL query on relational data will use a hash join and perform 10x to 100x faster, even for a single record. There seems to be no way for the optimizer to see the regularity in the XML structure and perform a corresponding optimization in joining the code tables. Not sure if registering a schema would help. Using structured storage probably would. But should that be necessary given we’re working with a single record?
    Operation Object
    |SELECT STATEMENT ()
    | SORT (AGGREGATE)
    | NESTED LOOPS (SEMI)
    | TABLE ACCESS (FULL) CODES
    | XPATH EVALUATION ()
    | SORT (AGGREGATE)
    | NESTED LOOPS (SEMI)
    | TABLE ACCESS (FULL) CODES
    | XPATH EVALUATION ()
    | SORT (AGGREGATE)
    | NESTED LOOPS (SEMI)
    | TABLE ACCESS (FULL) CODES
    | XPATH EVALUATION ()
    | SORT (AGGREGATE)
    | XPATH EVALUATION ()
    | SORT (AGGREGATE)
    | XPATH EVALUATION ()
    | TABLE ACCESS (BY INDEX ROWID) RECORDS
    | INDEX (RANGE SCAN) RECORDS_SSN
    With an xmlindex, the same query above runs in about 1 second, so is about 5x faster (0.2 sec/lookup), which is almost good enough. Is this the answer? Or is there a better way? I’m not sure why the optimizer wants to scan the code tables and index into the (one) XML record, rather than the other way around, but maybe that makes sense if the optimizer wants to use the same general plan as when the WHERE clause constraint is relaxed to multiple records.
    -- Add an xmlindex. Takes about 2.5 minutes
    create index records_record_xml ON records(xmlrec)
    indextype IS xdb.xmlindex;
    Operation Object
    |SELECT STATEMENT ()
    | SORT (GROUP BY)
    | FILTER ()
    | NESTED LOOPS ()
    | FAST DUAL ()
    | TABLE ACCESS (BY INDEX ROWID) SYS113473_RECORDS_R_PATH_TABLE
    | INDEX (RANGE SCAN) SYS113473_RECORDS_R_PATHID_IX
    | SORT (AGGREGATE)
    | FILTER ()
    | TABLE ACCESS (FULL) CODES
    | FILTER ()
    | NESTED LOOPS ()
    | FAST DUAL ()
    | TABLE ACCESS (BY INDEX ROWID) SYS113473_RECORDS_R_PATH_TABLE
    | INDEX (RANGE SCAN) SYS113473_RECORDS_R_PATHID_IX
    | SORT (GROUP BY)
    | FILTER ()
    | NESTED LOOPS ()
    | FAST DUAL ()
    | TABLE ACCESS (BY INDEX ROWID) SYS113473_RECORDS_R_PATH_TABLE
    | INDEX (RANGE SCAN) SYS113473_RECORDS_R_PATHID_IX
    | SORT (AGGREGATE)
    | FILTER ()
    | TABLE ACCESS (FULL) CODES
    | FILTER ()
    | NESTED LOOPS ()
    | FAST DUAL ()
    | TABLE ACCESS (BY INDEX ROWID) SYS113473_RECORDS_R_PATH_TABLE
    | INDEX (RANGE SCAN) SYS113473_RECORDS_R_PATHID_IX
    | SORT (GROUP BY)
    | FILTER ()
    | NESTED LOOPS ()
    | FAST DUAL ()
    | TABLE ACCESS (BY INDEX ROWID) SYS113473_RECORDS_R_PATH_TABLE
    | INDEX (RANGE SCAN) SYS113473_RECORDS_R_PATHID_IX
    | SORT (AGGREGATE)
    | FILTER ()
    | TABLE ACCESS (FULL) CODES
    | FILTER ()
    | NESTED LOOPS ()
    | FAST DUAL ()
    | TABLE ACCESS (BY INDEX ROWID) SYS113473_RECORDS_R_PATH_TABLE
    | INDEX (RANGE SCAN) SYS113473_RECORDS_R_PATHID_IX
    | SORT (AGGREGATE)
    | FILTER ()
    | NESTED LOOPS ()
    | FAST DUAL ()
    | TABLE ACCESS (BY INDEX ROWID) SYS113473_RECORDS_R_PATH_TABLE
    | INDEX (RANGE SCAN) SYS113473_RECORDS_R_PATHID_IX
    | SORT (AGGREGATE)
    | TABLE ACCESS (BY INDEX ROWID) SYS113473_RECORDS_R_PATH_TABLE
    | INDEX (RANGE SCAN) SYS113473_RECORDS_R_PATHID_IX
    | TABLE ACCESS (BY INDEX ROWID) RECORDS
    | INDEX (RANGE SCAN) RECORDS_SSN
    Am I on the right path, or am I totally using the wrong approach? I thought about using XSLT but was unsure how to reference the code tables.
    I’ve done the best I can constraining the main record to a single row passed to the XMLQUERY. Given Mark’s post (thanks!) should I be joining and constraining the code tables in the SQL WHERE clause too? That’s going to make the query much more complicated, but right now we’re more concerned about performance than complexity.

  • Problem in Writing to/Reading from a Binary file placed in a Loop

    Hi
    As you can see in the attahced image, I attempt to write a set of 2*202 data in each iteration of the loop of the loop, yet when I try to read the data (in the second picture) I only get the first (or last, I assume) set of data, up to index 202. I needed to read two set (X, Y) of 402 valuse. So, I am not sure if I am making a  mistake in wrting to the file or reading from it! 
    I really appreciate it if someone could suggest a solution
    Ashakn
     

    You are only reading the first.  In your read, set your number to read to -1.  That will tell the Read Binary File to read all of the data instead just a single set.

  • Problems with Vista and Reader 8.12 - unusual problem need help

    I can't seem to find anyone to help me or any record of someone else having this problem. As soon as I install reader 8.12 on my new system (Vista) it begins 'hijacking' other files. In other words other icons on my desktop (e.g., the icon for AOL IM) turn into PDF icons and so when I try to launch an .exe file - Reader launches instead and of course tells me it can't open the file. This is so maddening. I've installed and unstalled the program several times and have rebooted. I've tried to contact Adobe but they will not provide support, I've contacted Gateway and they say it's an Adobe issue and Microsoft won't speak with me because Vista was pre-installed on the computer. If anyone has any ideas and can assist me I'd greatly appreciate it. For now I just have to leave the program uninstalled and therefore can't open any PDFs.
    Anita

    It seems that in Vista bad things may happen if you ever choose a
    program to open downloaded EXE files.
    This may help with the EXE issue:
    http://www.winhelponline.com/articles/165/1/Restore-the-exe-file-association-in-Windows-Vi sta-after-incorrectly-associating-it-with-another-application.html
    Aandi Inston

  • Erased disk - BIG problems with OSX and restoring from TM

    Hi,
    Please bare with me here - I've been trying to solve this problem across the last 3 days.
    I was advised by a friend to do a fresh install of OSX after erasing my current in internal HDD (2009 Macbook Pro 13").
    I 1st confirmed that time machine had a complete back-up on my external USB drive
    I followed the instructions via the OSX install disk, erased the current drive and then completed the OSX re-install.
    When the time came to migrate, I received a screen message stating that my time machine back-up contains a newer version of OSX and therefore could not be migrated.
    I allowed the new OSX install to complete and then updated to the latest version of OSX.
    I opened migration assistant and followed the instructions to restore my last time machine back-up. This took a while but seemed to work.
    I rebooted and was only able to find the clean OSX install - I could not locate the restored files from time machine - not anywhere. However my HDD was now showing a free space of 140Gb (of a total 500) so something had been restored.
    I spent many hrs looking and in the end went back to square one - erased HDD and reinstalled OSX.
    This is the point I'm at now and I have no idea how to get my time machine back-up restored?????

    Please bare with me here
    What exactly are we going to bare!
    I was advised by a friend to do a fresh install of OSX after erasing my current in internal HDD (2009 Macbook Pro 13").
    Assuming you had a very good reason and you guys had tried everything else including an archive and install of course
    I rebooted and was only able to find the clean OSX install - I could not locate the restored files from time machine - not anywhere.
    Did you check for invisible folders in your users folder i.e "ls -a /Users/" ?
    I spent many hrs looking and in the end went back to square one - erased HDD and reinstalled OSX.
    Hmmm you could have asked here before square one but regardless check this forum out http://discussions.apple.com/forum.jspa?forumID=1227&start=0. At the top you will find tips by Pondini which will tell you at the very least how to get your old system back. Also what you did I think probably worked as well and you just didn't check /Users/.name/
    edit: you could also go from where you are now and manually bring your stuff over. Might be best option depending on how badly your original system was mucked up to cause you to do a wipe-install.
    Message was edited by: taylor.henderson

  • Problem with ID and download from app store:computer or device could not be verified

    Hello.I have mac and i had one game from app store,but one day i couldnt open it,it ased me to ented my App ID and password,,,i did but it wrote to meYour device or computer could not be verified. Contact support for assistance. I allready chande my password and mad ned ID but nothing works.....the same problem.how can i download from app store again.thanks

    Try a forum more suited:
    https://discussions.apple.com/community/mac_app_store/using_mac_apple_store?view =discussions

  • Problem with encoding and charset for downloading a file

    Hi guys, I have a problem and I beg for your help, I am 1000% frustrated at this point.
    I have a servlet which have to do something and give a file log to the final user. Coding the logic for that took me about 5 minutes, the problem is that the given file doesnt shows properly in notepad (Default app to open txt files). I have tried every way I have read over the internet and absolutely nothing works.
    After trying about 20 different ways fo doing this without success, this is my actual code:
    Charset def=Charset.defaultCharset();
    OutputStreamWriter out = new OutputStreamWriter(servletOutputStream,def);
    for (String registry:regList) {
    out.write(registry+"\n");
    out.close();
    the page gives the file to the user, I can download or open it, when I open it this is the result
    registry1registry2registry3registry4registry5registry6registry7...
    and I am expecting:
    registry1
    registry2
    registry3
    registry4
    registry5
    If I open it with wordpad or notepad++ the file looks fine, but I cant achieve that notepad reads it correctly. I have spent about 10 hours on this and at this point I just dont know what to do, i have tried Windows-1252, UTF-8, UTF-16, the Default one. I have tried to set this enconding on the response header with no luck. Any help will be very appreciated.
    Thanks in advance.

    >
    I have a servlet which have to do something and give a file log to the final user. Coding the logic for that took me about 5 minutes, the problem is that the given file doesnt shows properly in notepad (Default app to open txt files). I have tried every way I have read over the internet and absolutely nothing works.
    If I open it with wordpad or notepad++ the file looks fine, but I cant achieve that notepad reads it correctly. I have spent about 10 hours on this and at this point I just dont know what to do, i have tried Windows-1252, UTF-8, UTF-16, the Default one. I have tried to set this enconding on the response header with no luck. Any help will be very appreciated.
    >
    Your file likely uses *nix style line endings and use a single LF (0x0A) as the end of each line.
    Notepad doesn't recognize a single LF as the end of line; it expects CRLF (0x0D0A). The encoding isn't the issue.
    If you have to use Notepad you will need to add code to find all of the LF characters and insert a CR character in front of them.

  • Why FireFox 3.6 has problem with expand and colapsed in sharepoint data view?

    I used an script in this page http://www.sgnec.net/pages/customers/customers.aspx. It worked well. but now I found it doesn't work with Firefox 3.6 . when I clicked plus image it doesn't collapsed.
    thanks
    Leila

    Try the Firefox Portable support forum. <br />
    http://portableapps.com/forums/support/firefox_portable

  • Open and read from text file into a text box for Windows Store

    I wish to open and read from a text file into a text box in C# for the Windows Store using VS Express 2012 for Windows 8.
    Can anyone point me to sample code and tutorials specifically for Windows Store using C#.
    Is it possible to add a Text file in Windows Store. This option only seems to be available in Visual C#.
    Thanks
    Wendel

    This is a simple sample for Read/Load Text file from IsolateStorage and Read file from InstalledLocation (this folder only can be read)
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Storage;
    using System.IO;
    namespace TextFileDemo
    public class TextFileHelper
    async public static Task<bool> SaveTextFileToIsolateStorageAsync(string filename, string data)
    byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(data);
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    var file = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
    try
    using (var s = await file.OpenStreamForWriteAsync())
    s.Write(fileBytes, 0, fileBytes.Length);
    return true;
    catch
    return false;
    async public static Task<string> LoadTextFileFormIsolateStorageAsync(string filename)
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    async public static Task<string> LoadTextFileFormInstalledLocationAsync(string filename)
    StorageFolder local = Windows.ApplicationModel.Package.Current.InstalledLocation;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    show how to use it as below
    async private void Button_Click(object sender, RoutedEventArgs e)
    string txt =await TextFileHelper.LoadTextFileFormInstalledLocationAsync("TextFile1.txt");
    Debug.WriteLine(txt);
    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

Maybe you are looking for

  • How can i create a mask of grays?

    Hi i did learn how create a saturation mask (a mask that contains the colors) how can i create a mask with the grays ? can i do it? how can  i create it ? the only way i can thing it's use a color selective adjustament layer and set to +100 black eve

  • Drag and Drop Learning Interaction without Overlapping

    I would like to be able to drag and drop into a column without dragged items overlapping for a quiz question. I don't know Action Script and am using CS3. What do I need to do to get this to work. Component Inspector states Drag1 = Target 1, etc. I n

  • Dead Line

    I reported a fault on my line on 20th Jan via the online fault reporter, which said it should be fixed within 3 working days. It has been over a week now and nothing has changed.  The site also said it would keep me updated witht he latest progress b

  • Table Maintenace validations on screen

    I would like to know as to how we can include validations while entering data into a ZTABLE. I create a z-table and generate table maintenance. When the user enters data in the table i would like to auto populate 1 of the table fields based on other

  • Printing to a Epson Stylus Pro7800 on OS X Mountain Lion

    I wonder if I should Upgrade my IMac,  from snow leopard (10.6.8) to Mountain Lion. My work depends on printing from Adobe CS6 PShop and Illustrator to a Epson stylus Pro 7800 printer. Has any body experience or knows if this printer is supported on