| 214 | } |
| 215 | |
| 216 | public void writeTo(File file, byte[] data) throws IOException { |
| 217 | if (file.isDirectory()) { |
| 218 | throw new IOException(String.format("Can't write to an existing directory(%s)", file)); |
| 219 | } |
| 220 | |
| 221 | Dir.INSTANCE.createDir(file.getParentFile()); |
| 222 | |
| 223 | FileOutputStream fos = new FileOutputStream(file); |
| 224 | |
| 225 | try { |
| 226 | fos.write(data); |
| 227 | } finally { |
| 228 | try { |
| 229 | fos.close(); |
| 230 | } catch (IOException e) { |
| 231 | // ignore it |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | public void writeTo(File file, String data) throws IOException { |
| 237 | writeTo(file, data, "utf-8"); |