1 32 package net.sf.retrotranslator.transformer; 33 34 import java.io.*; 35 import java.util.Collection ; 36 37 40 abstract class FileContainer { 41 42 protected File location; 43 44 protected FileContainer(File location) { 45 this.location = location; 46 } 47 48 public File getLocation() { 49 return location; 50 } 51 52 public abstract Collection <? extends FileEntry> getEntries(); 53 54 public abstract void removeEntry(String name); 55 56 public abstract void putEntry(String name, byte[] contents); 57 58 public abstract void flush(SystemLogger logger); 59 60 protected static byte[] readFully(InputStream stream, int length) throws IOException { 61 if (length <= 0) length = 0x8000; 62 byte[] buffer = new byte[length]; 63 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(length); 64 int count; 65 while((count = stream.read(buffer)) > 0) { 66 outputStream.write(buffer, 0, count); 67 } 68 return outputStream.toByteArray(); 69 } 70 71 public String toString() { 72 return location.toString(); 73 } 74 75 public int getFileCount() { 76 return getEntries().size(); 77 } 78 79 } 80 | Popular Tags |