public void getState(OutputStream ostream) throws Exception { HashMap<K,V> copy=new HashMap<>(); for(Map.Entry<K,V> entry:entrySet()) { K key=entry.getKey(); V val=entry.getValue(); copy.put(key, val); } try(ObjectOutputStream oos=new ObjectOutputStream(new BufferedOutputStream(ostream, 1024))) { oos.writeObject(copy); } }
private void showAll() { if(listbox.getItemCount() > 0) listbox.removeAll(); if(map.isEmpty()) return; clearMsg(); String key; Float val; for(Map.Entry<String,Float> entry: map.entrySet()) { key=entry.getKey(); val=entry.getValue(); if(val == null) continue; listbox.add(key + ": " + val.toString()); } }
public void getState(OutputStream ostream) throws Exception { HashMap<K,V> copy=new HashMap<>(); for(Map.Entry<K,V> entry:entrySet()) { K key=entry.getKey(); V val=entry.getValue(); copy.put(key, val); } try(ObjectOutputStream oos=new ObjectOutputStream(new BufferedOutputStream(ostream, 1024))) { oos.writeObject(copy); } }
public byte[] getState() { K key; V val; Map<K,V> copy=new HashMap<K,V>(); for(Map.Entry<K,V> entry: entrySet()) { key=entry.getKey(); val=entry.getValue(); copy.put(key, val); } try { return Util.objectToByteBuffer(copy); } catch(Throwable ex) { if(log.isErrorEnabled()) log.error("exception marshalling state: " + ex); return null; } }
public void getState(OutputStream ostream) { K key; V val; HashMap<K,V> copy=new HashMap<K,V>(); ObjectOutputStream oos=null; for(Map.Entry<K,V> entry: entrySet()) { key=entry.getKey(); val=entry.getValue(); copy.put(key, val); } try { oos=new ObjectOutputStream(ostream); oos.writeObject(copy); } catch(Throwable ex) { if(log.isErrorEnabled()) log.error("exception marshalling state: " + ex); } finally { Util.close(oos); } }
private void showAll() { if(listbox.getItemCount() > 0) listbox.removeAll(); if(map.isEmpty()) return; clearMsg(); String key; Float val; for(Map.Entry<String,Float> entry: map.entrySet()) { key=entry.getKey(); val=entry.getValue(); if(val == null) continue; listbox.add(key + ": " + val.toString()); } }