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 make72Safe(buffer);
161 buffer.append("\r\n");
162 dos.writeBytes(buffer.toString());
163 e.getValue().write(dos);
164 }
165 dos.flush();
166 }
167
168 /**
169 * Adds line breaks to enforce a maximum 72 bytes per line.
170 */
171 static void make72Safe(StringBuffer line) {
|
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 per-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 make72Safe(buffer);
161 buffer.append("\r\n");
162 dos.writeBytes(buffer.toString());
163 e.getValue().write(dos);
164 }
165 dos.flush();
166 }
167
168 /**
169 * Adds line breaks to enforce a maximum 72 bytes per line.
170 */
171 static void make72Safe(StringBuffer line) {
|