Changeset 2626 in josm for trunk/src/org/openstreetmap/josm/io/MultiPartFormOutputStream.java
- Timestamp:
- 2009-12-13T11:48:12+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/MultiPartFormOutputStream.java
r2512 r2626 8 8 are permitted provided that the following conditions are met: 9 9 10 10 * Redistribution of source code must retain the above copyright notice, this list 11 11 of conditions and the following disclaimer. 12 12 13 13 * Redistribution in binary form must reproduce the above copyright notice, this 14 14 list of conditions and the following disclaimer in the documentation and/or other 15 15 materials provided with the distribution. … … 31 31 You acknowledge that this software is not designed, licensed or intended for use in the 32 32 design, construction, operation or maintenance of any nuclear facility. 33 */33 */ 34 34 35 35 package org.openstreetmap.josm.io; … … 86 86 */ 87 87 public MultiPartFormOutputStream(OutputStream os, String boundary) { 88 if(os == null) {88 if(os == null) 89 89 throw new IllegalArgumentException("Output stream is required."); 90 } 91 if(boundary == null || boundary.length() == 0) { 90 if(boundary == null || boundary.length() == 0) 92 91 throw new IllegalArgumentException("Boundary stream is required."); 93 }94 92 this.out = new DataOutputStream(os); 95 93 this.boundary = boundary; … … 106 104 public void writeField(String name, boolean value) 107 105 throws java.io.IOException { 108 writeField(name, new Boolean(value).toString());106 writeField(name, Boolean.valueOf(value).toString()); 109 107 } 110 108 … … 178 176 public void writeField(String name, char value) 179 177 throws java.io.IOException { 180 writeField(name, new Character(value).toString());178 writeField(name, Character.valueOf(value).toString()); 181 179 } 182 180 … … 191 189 public void writeField(String name, String value) 192 190 throws java.io.IOException { 193 if(name == null) {191 if(name == null) 194 192 throw new IllegalArgumentException("Name cannot be null or empty."); 195 }196 193 if(value == null) { 197 194 value = ""; … … 229 226 public void writeFile(String name, String mimeType, java.io.File file) 230 227 throws java.io.IOException { 231 if(file == null) {228 if(file == null) 232 229 throw new IllegalArgumentException("File cannot be null."); 233 } 234 if(!file.exists()) { 230 if(!file.exists()) 235 231 throw new IllegalArgumentException("File does not exist."); 236 } 237 if(file.isDirectory()) { 232 if(file.isDirectory()) 238 233 throw new IllegalArgumentException("File cannot be a directory."); 239 }240 234 writeFile(name, mimeType, file.getCanonicalPath(), new FileInputStream(file)); 241 235 } … … 254 248 String fileName, InputStream is) 255 249 throws java.io.IOException { 256 if(is == null) {250 if(is == null) 257 251 throw new IllegalArgumentException("Input stream cannot be null."); 258 } 259 if(fileName == null || fileName.length() == 0) { 252 if(fileName == null || fileName.length() == 0) 260 253 throw new IllegalArgumentException("File name cannot be null or empty."); 261 }262 254 /* 263 255 --boundary\r\n … … 308 300 String fileName, byte[] data) 309 301 throws java.io.IOException { 310 if(data == null) {302 if(data == null) 311 303 throw new IllegalArgumentException("Data cannot be null."); 312 } 313 if(fileName == null || fileName.length() == 0) { 304 if(fileName == null || fileName.length() == 0) 314 305 throw new IllegalArgumentException("File name cannot be null or empty."); 315 }316 306 /* 317 307 --boundary\r\n
Note:
See TracChangeset
for help on using the changeset viewer.