126 return getEntries().get(name);
127 }
128
129 /**
130 * Clears the main Attributes as well as the entries in this Manifest.
131 */
132 public void clear() {
133 attr.clear();
134 entries.clear();
135 }
136
137 /**
138 * Writes the Manifest to the specified OutputStream.
139 * Attributes.Name.MANIFEST_VERSION must be set in
140 * MainAttributes prior to invoking this method.
141 *
142 * @param out the output stream
143 * @exception IOException if an I/O error has occurred
144 * @see #getMainAttributes
145 */
146 public void write(OutputStream out) throws IOException {
147 DataOutputStream dos = new DataOutputStream(out);
148 // Write out the main attributes for the manifest
149 attr.writeMain(dos);
150 // Now write out the pre-entry attributes
151 for (Map.Entry<String, Attributes> e : entries.entrySet()) {
152 StringBuffer buffer = new StringBuffer("Name: ");
153 String value = e.getKey();
154 if (value != null) {
155 byte[] vb = value.getBytes("UTF8");
156 value = new String(vb, 0, 0, vb.length);
157 }
158 buffer.append(value);
159 buffer.append("\r\n");
160 make72Safe(buffer);
161 dos.writeBytes(buffer.toString());
162 e.getValue().write(dos);
163 }
164 dos.flush();
165 }
|
126 return getEntries().get(name);
127 }
128
129 /**
130 * Clears the main Attributes as well as the entries in this Manifest.
131 */
132 public void clear() {
133 attr.clear();
134 entries.clear();
135 }
136
137 /**
138 * Writes the Manifest to the specified OutputStream.
139 * Attributes.Name.MANIFEST_VERSION must be set in
140 * MainAttributes prior to invoking this method.
141 *
142 * @param out the output stream
143 * @exception IOException if an I/O error has occurred
144 * @see #getMainAttributes
145 */
146 @SuppressWarnings("deprecation")
147 public void write(OutputStream out) throws IOException {
148 DataOutputStream dos = new DataOutputStream(out);
149 // Write out the main attributes for the manifest
150 attr.writeMain(dos);
151 // Now write out the pre-entry attributes
152 for (Map.Entry<String, Attributes> e : entries.entrySet()) {
153 StringBuffer buffer = new StringBuffer("Name: ");
154 String value = e.getKey();
155 if (value != null) {
156 byte[] vb = value.getBytes("UTF8");
157 value = new String(vb, 0, 0, vb.length);
158 }
159 buffer.append(value);
160 buffer.append("\r\n");
161 make72Safe(buffer);
162 dos.writeBytes(buffer.toString());
163 e.getValue().write(dos);
164 }
165 dos.flush();
166 }
|