equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
362 * |
362 * |
363 * @since Java for Mac OS X 10.6 Update 1 - 1.6 |
363 * @since Java for Mac OS X 10.6 Update 1 - 1.6 |
364 * @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5 |
364 * @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5 |
365 */ |
365 */ |
366 public static boolean moveToTrash(final File file) throws FileNotFoundException { |
366 public static boolean moveToTrash(final File file) throws FileNotFoundException { |
367 if (file == null || !file.exists()) throw new FileNotFoundException(); |
367 if (file == null) throw new FileNotFoundException(); |
368 final String fileName = file.getAbsolutePath(); |
368 final String fileName = file.getAbsolutePath(); |
369 |
369 |
370 final SecurityManager security = System.getSecurityManager(); |
370 final SecurityManager security = System.getSecurityManager(); |
371 if (security != null) security.checkWrite(fileName); |
371 if (security != null) security.checkDelete(fileName); |
372 |
372 |
373 return _moveToTrash(fileName); |
373 return _moveToTrash(fileName); |
374 } |
374 } |
375 |
375 |
376 private static native boolean _moveToTrash(String fileName); |
376 private static native boolean _moveToTrash(String fileName); |