1147 * file or directory in the directory that it denotes.
1148 *
1149 * @param filter
1150 * A filename filter
1151 *
1152 * @return An array of strings naming the files and directories in the
1153 * directory denoted by this abstract pathname that were accepted
1154 * by the given {@code filter}. The array will be empty if the
1155 * directory is empty or if no names were accepted by the filter.
1156 * Returns {@code null} if this abstract pathname does not denote
1157 * a directory, or if an I/O error occurs.
1158 *
1159 * @throws SecurityException
1160 * If a security manager exists and its {@link
1161 * SecurityManager#checkRead(String)} method denies read access to
1162 * the directory
1163 *
1164 * @see java.nio.file.Files#newDirectoryStream(Path,String)
1165 */
1166 public String[] list(FilenameFilter filter) {
1167 String names[] = list();
1168 if ((names == null) || (filter == null)) {
1169 return names;
1170 }
1171 List<String> v = new ArrayList<>();
1172 for (int i = 0 ; i < names.length ; i++) {
1173 if (filter.accept(this, names[i])) {
1174 v.add(names[i]);
1175 }
1176 }
1177 return v.toArray(new String[v.size()]);
1178 }
1179
1180 /**
1181 * Returns an array of abstract pathnames denoting the files in the
1182 * directory denoted by this abstract pathname.
1183 *
1184 * <p> If this abstract pathname does not denote a directory, then this
1185 * method returns {@code null}. Otherwise an array of {@code File} objects
1186 * is returned, one for each file or directory in the directory. Pathnames
1187 * denoting the directory itself and the directory's parent directory are
1240 * the directory that it denotes.
1241 *
1242 * @param filter
1243 * A filename filter
1244 *
1245 * @return An array of abstract pathnames denoting the files and
1246 * directories in the directory denoted by this abstract pathname.
1247 * The array will be empty if the directory is empty. Returns
1248 * {@code null} if this abstract pathname does not denote a
1249 * directory, or if an I/O error occurs.
1250 *
1251 * @throws SecurityException
1252 * If a security manager exists and its {@link
1253 * SecurityManager#checkRead(String)} method denies read access to
1254 * the directory
1255 *
1256 * @since 1.2
1257 * @see java.nio.file.Files#newDirectoryStream(Path,String)
1258 */
1259 public File[] listFiles(FilenameFilter filter) {
1260 String ss[] = list();
1261 if (ss == null) return null;
1262 ArrayList<File> files = new ArrayList<>();
1263 for (String s : ss)
1264 if ((filter == null) || filter.accept(this, s))
1265 files.add(new File(s, this));
1266 return files.toArray(new File[files.size()]);
1267 }
1268
1269 /**
1270 * Returns an array of abstract pathnames denoting the files and
1271 * directories in the directory denoted by this abstract pathname that
1272 * satisfy the specified filter. The behavior of this method is the same
1273 * as that of the {@link #listFiles()} method, except that the pathnames in
1274 * the returned array must satisfy the filter. If the given {@code filter}
1275 * is {@code null} then all pathnames are accepted. Otherwise, a pathname
1276 * satisfies the filter if and only if the value {@code true} results when
1277 * the {@link FileFilter#accept FileFilter.accept(File)} method of the
1278 * filter is invoked on the pathname.
1279 *
1280 * @param filter
1281 * A file filter
1282 *
1283 * @return An array of abstract pathnames denoting the files and
1284 * directories in the directory denoted by this abstract pathname.
1285 * The array will be empty if the directory is empty. Returns
1286 * {@code null} if this abstract pathname does not denote a
1287 * directory, or if an I/O error occurs.
1288 *
1289 * @throws SecurityException
1290 * If a security manager exists and its {@link
1291 * SecurityManager#checkRead(String)} method denies read access to
1292 * the directory
1293 *
1294 * @since 1.2
1295 * @see java.nio.file.Files#newDirectoryStream(Path,java.nio.file.DirectoryStream.Filter)
1296 */
1297 public File[] listFiles(FileFilter filter) {
1298 String ss[] = list();
1299 if (ss == null) return null;
1300 ArrayList<File> files = new ArrayList<>();
1301 for (String s : ss) {
1302 File f = new File(s, this);
1303 if ((filter == null) || filter.accept(f))
1304 files.add(f);
1305 }
1306 return files.toArray(new File[files.size()]);
1307 }
1308
1309 /**
1310 * Creates the directory named by this abstract pathname.
1311 *
1312 * @return <code>true</code> if and only if the directory was
1313 * created; <code>false</code> otherwise
1314 *
1315 * @throws SecurityException
1316 * If a security manager exists and its {@link
1317 * java.lang.SecurityManager#checkWrite(java.lang.String)}
1318 * method does not permit the named directory to be created
|
1147 * file or directory in the directory that it denotes.
1148 *
1149 * @param filter
1150 * A filename filter
1151 *
1152 * @return An array of strings naming the files and directories in the
1153 * directory denoted by this abstract pathname that were accepted
1154 * by the given {@code filter}. The array will be empty if the
1155 * directory is empty or if no names were accepted by the filter.
1156 * Returns {@code null} if this abstract pathname does not denote
1157 * a directory, or if an I/O error occurs.
1158 *
1159 * @throws SecurityException
1160 * If a security manager exists and its {@link
1161 * SecurityManager#checkRead(String)} method denies read access to
1162 * the directory
1163 *
1164 * @see java.nio.file.Files#newDirectoryStream(Path,String)
1165 */
1166 public String[] list(FilenameFilter filter) {
1167 String[] names = list();
1168 if ((names == null) || (filter == null)) {
1169 return names;
1170 }
1171 List<String> v = new ArrayList<>();
1172 for (int i = 0 ; i < names.length ; i++) {
1173 if (filter.accept(this, names[i])) {
1174 v.add(names[i]);
1175 }
1176 }
1177 return v.toArray(new String[v.size()]);
1178 }
1179
1180 /**
1181 * Returns an array of abstract pathnames denoting the files in the
1182 * directory denoted by this abstract pathname.
1183 *
1184 * <p> If this abstract pathname does not denote a directory, then this
1185 * method returns {@code null}. Otherwise an array of {@code File} objects
1186 * is returned, one for each file or directory in the directory. Pathnames
1187 * denoting the directory itself and the directory's parent directory are
1240 * the directory that it denotes.
1241 *
1242 * @param filter
1243 * A filename filter
1244 *
1245 * @return An array of abstract pathnames denoting the files and
1246 * directories in the directory denoted by this abstract pathname.
1247 * The array will be empty if the directory is empty. Returns
1248 * {@code null} if this abstract pathname does not denote a
1249 * directory, or if an I/O error occurs.
1250 *
1251 * @throws SecurityException
1252 * If a security manager exists and its {@link
1253 * SecurityManager#checkRead(String)} method denies read access to
1254 * the directory
1255 *
1256 * @since 1.2
1257 * @see java.nio.file.Files#newDirectoryStream(Path,String)
1258 */
1259 public File[] listFiles(FilenameFilter filter) {
1260 String[] ss = list();
1261 if (ss == null) return null;
1262 ArrayList<File> files = new ArrayList<>();
1263 for (String s : ss)
1264 if ((filter == null) || filter.accept(this, s))
1265 files.add(new File(s, this));
1266 return files.toArray(new File[files.size()]);
1267 }
1268
1269 /**
1270 * Returns an array of abstract pathnames denoting the files and
1271 * directories in the directory denoted by this abstract pathname that
1272 * satisfy the specified filter. The behavior of this method is the same
1273 * as that of the {@link #listFiles()} method, except that the pathnames in
1274 * the returned array must satisfy the filter. If the given {@code filter}
1275 * is {@code null} then all pathnames are accepted. Otherwise, a pathname
1276 * satisfies the filter if and only if the value {@code true} results when
1277 * the {@link FileFilter#accept FileFilter.accept(File)} method of the
1278 * filter is invoked on the pathname.
1279 *
1280 * @param filter
1281 * A file filter
1282 *
1283 * @return An array of abstract pathnames denoting the files and
1284 * directories in the directory denoted by this abstract pathname.
1285 * The array will be empty if the directory is empty. Returns
1286 * {@code null} if this abstract pathname does not denote a
1287 * directory, or if an I/O error occurs.
1288 *
1289 * @throws SecurityException
1290 * If a security manager exists and its {@link
1291 * SecurityManager#checkRead(String)} method denies read access to
1292 * the directory
1293 *
1294 * @since 1.2
1295 * @see java.nio.file.Files#newDirectoryStream(Path,java.nio.file.DirectoryStream.Filter)
1296 */
1297 public File[] listFiles(FileFilter filter) {
1298 String[] ss = list();
1299 if (ss == null) return null;
1300 ArrayList<File> files = new ArrayList<>();
1301 for (String s : ss) {
1302 File f = new File(s, this);
1303 if ((filter == null) || filter.accept(f))
1304 files.add(f);
1305 }
1306 return files.toArray(new File[files.size()]);
1307 }
1308
1309 /**
1310 * Creates the directory named by this abstract pathname.
1311 *
1312 * @return <code>true</code> if and only if the directory was
1313 * created; <code>false</code> otherwise
1314 *
1315 * @throws SecurityException
1316 * If a security manager exists and its {@link
1317 * java.lang.SecurityManager#checkWrite(java.lang.String)}
1318 * method does not permit the named directory to be created
|