issues with duplicate value
I have a function that searches a folder for images, and then gives the images a name, and then calls a function that sends them to a server. for some reason it continues to keep the same name when i call the contact.setImageName()..here is my code and a sample output of 4 images entered
publicvoid updateContactImage(){
if (currentC_ID == 0){
JOptionPane.showMessageDialog(null,"Error - Please Enter or Select a Contact","Error", JOptionPane.DEFAULT_OPTION);
}else{
String fileName ="";
String inputValue ="";
String path ="C:\\Images\\";
boolean exists = (new File(path)).exists();
if (exists){
File folder =new File(path);
File[] listOfFiles = folder.listFiles();
if (listOfFiles.length >0){
for (int i = 0; i < listOfFiles.length; i++){
if (listOfFiles[i].isFile()){
fileName = listOfFiles[i].getAbsolutePath();
if (fileName.endsWith(".jpeg") || fileName.endsWith(".jpg") || fileName.endsWith(".JPG") || fileName.endsWith(".JPEG")){// || fileName.endsWith(".avi")){
try{
FileInputStream input =new FileInputStream(new File(fileName));
ByteArrayOutputStream output =new ByteArrayOutputStream();
byte[] buf =newbyte[1024];
byte[] data =null;
int numBytesRead = 0;
while ((numBytesRead = input.read(buf)) != -1){
output.write(buf, 0, numBytesRead);
}
contact =new contactObject();
System.out.println("contact.getImageName()= " + contact.getImageName());
System.out.println("inputeValue = " + inputValue);
contact.setAction("updateImage");
contact.setP_ID(currentC_ID);
inputValue = JOptionPane.showInputDialog("Input name for image:");
System.out.println("inputValue = " + inputValue +" time = " + getTime());
contact.setImageName(inputValue +" " + getTime());
contact.setImage(output.toByteArray());
System.out.println("Image file name = " + contact.getImageName());
sendContact();
output.close();
input.close();
}catch (FileNotFoundException ex){
ex.printStackTrace();
}catch (IOException ex){
ex.printStackTrace();
}
}
}elseif (listOfFiles[i].isDirectory()){
System.out.println("Directory " + listOfFiles[i].getName());
}
}
}else{
JOptionPane.showMessageDialog(null,"There are no files to submit");
}
}else{
System.out.println("directory does not exist");
}
}
contact =new contactObject();
}
contact.getImageName()= null
inputeValue =
inputValue = 1 time = 04-13-2007-06-33-12
Image file name = 1 04-13-2007-06-33-12
contact.getImageName()= null
inputeValue = 1
inputValue = 2 time = 04-13-2007-06-33-13
Image file name = 1 04-13-2007-06-33-12
contact.getImageName()= null
inputeValue = 2
inputValue = 3 time = 04-13-2007-06-33-16
Image file name = 1 04-13-2007-06-33-12
contact.getImageName()= null
inputeValue = 3
inputValue = 4 time = 04-13-2007-06-33-17
Image file name = 1 04-13-2007-06-33-12
for some reason when setting the contact.setImageName() it keeps the value of the previous one. here is my code for contact.setImageName()
public void setImageName(String newImage){
imageName[imageNameCount] = newImage;
imageNameCount++;
}
thanks for any help

