1 33 34 package com.icesoft.applications.faces.auctionMonitor; 35 36 import com.icesoft.applications.faces.auctionMonitor.beans.AuctionBean; 37 import org.apache.commons.logging.Log; 38 import org.apache.commons.logging.LogFactory; 39 40 import java.io.BufferedReader ; 41 import java.io.IOException ; 42 import java.io.Reader ; 43 import java.util.Hashtable ; 44 45 50 public class AddAuctionItem extends AuctionBean { 51 private static Log log = LogFactory.getLog(AddAuctionItem.class); 52 53 public static Hashtable parseFile(Reader reader) { 54 BufferedReader in = new BufferedReader (reader); 55 Hashtable params = new Hashtable (); 56 String line; 57 try { 58 String name; 59 String value; 60 while (null != (line = in.readLine())) { 61 int index = line.indexOf(' '); 62 name = line.substring(0, index); 63 value = line.substring(index + 1); 64 params.put(name, value); 65 } 66 } catch (IOException e) { 67 if (log.isErrorEnabled()) { 68 log.error( 69 "Error while parsing an auction item file into the hashtable"); 70 } 71 } 72 return params; 73 } 74 75 public static String getPictureName(String fileName) { 76 int index = fileName.lastIndexOf('.'); 77 return (fileName.substring(0, index) + ".jpg"); 78 } 79 80 } 81 | Popular Tags |