Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2014-04-15 19:22:53 +0000
committerJoakim Erdfelt2014-04-15 19:22:53 +0000
commitdc3362ba3c1dded62f8434d1418f0c6bbcc8ef17 (patch)
tree81e849dae0504afe186555414e4a8ff88b7cf7dd /jetty-start
parent2dc10da3a42e8cb51893fce807508f582e2764a9 (diff)
downloadorg.eclipse.jetty.project-dc3362ba3c1dded62f8434d1418f0c6bbcc8ef17.tar.gz
org.eclipse.jetty.project-dc3362ba3c1dded62f8434d1418f0c6bbcc8ef17.tar.xz
org.eclipse.jetty.project-dc3362ba3c1dded62f8434d1418f0c6bbcc8ef17.zip
Removing deprecated methods
Diffstat (limited to 'jetty-start')
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/FS.java56
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/StartIni.java10
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java40
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java2
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/FSTest.java6
5 files changed, 25 insertions, 89 deletions
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/FS.java b/jetty-start/src/main/java/org/eclipse/jetty/start/FS.java
index 29ee31def2..9b55b45c0a 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/FS.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/FS.java
@@ -29,21 +29,11 @@ import java.util.Locale;
public class FS
{
- public static boolean canReadDirectory(File path)
- {
- return (path.exists() && path.isDirectory() && path.canRead());
- }
-
public static boolean canReadDirectory(Path path)
{
return Files.exists(path) && Files.isDirectory(path) && Files.isReadable(path);
}
- public static boolean canReadFile(File path)
- {
- return (path.exists() && path.isFile() && path.canRead());
- }
-
public static boolean canReadFile(Path path)
{
return Files.exists(path) && Files.isRegularFile(path) && Files.isReadable(path);
@@ -77,22 +67,6 @@ public class FS
return Files.exists(ret);
}
- /**
- * @deprecated use {@link #ensureDirectoryExists(Path)} instead
- */
- @Deprecated
- public static void ensureDirectoryExists(File dir) throws IOException
- {
- if (dir.exists())
- {
- return;
- }
- if (!dir.mkdirs())
- {
- throw new IOException("Unable to create directory: " + dir.getAbsolutePath());
- }
- }
-
public static void ensureDirectoryExists(Path dir) throws IOException
{
if (exists(dir))
@@ -103,22 +77,6 @@ public class FS
Files.createDirectories(dir);
}
- /**
- * @deprecated use {@link #ensureDirectoryWritable(Path)} instead
- */
- @Deprecated
- public static void ensureDirectoryWritable(File dir) throws IOException
- {
- if (!dir.exists())
- {
- throw new IOException("Directory does not exist: " + dir.getAbsolutePath());
- }
- if (!dir.canWrite())
- {
- throw new IOException("Unable to write to directory: " + dir.getAbsolutePath());
- }
- }
-
public static void ensureDirectoryWritable(Path dir) throws IOException
{
if (!Files.exists(dir))
@@ -140,15 +98,6 @@ public class FS
return Files.exists(path);
}
- public static boolean isFile(File file)
- {
- if (file == null)
- {
- return false;
- }
- return file.exists() && file.isFile();
- }
-
public static boolean isValidDirectory(Path path)
{
if (!Files.exists(path))
@@ -194,11 +143,6 @@ public class FS
return FileSystems.getDefault().getPath(FS.separators(path));
}
- public static String toRelativePath(File baseDir, File path)
- {
- return baseDir.toURI().relativize(path.toURI()).toASCIIString();
- }
-
public static void touch(Path path) throws IOException
{
FileTime now = FileTime.fromMillis(System.currentTimeMillis());
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartIni.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartIni.java
index 79b079cd71..524f958bd4 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartIni.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartIni.java
@@ -18,7 +18,6 @@
package org.eclipse.jetty.start;
-import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
@@ -29,16 +28,11 @@ public class StartIni extends TextFile
{
private Path basedir;
- public StartIni(File file) throws IOException
+ public StartIni(Path file) throws IOException
{
super(file);
}
- public StartIni(Path path) throws IOException
- {
- this(path.toFile());
- }
-
@Override
public void addUniqueLine(String line)
{
@@ -70,7 +64,7 @@ public class StartIni extends TextFile
@Override
public void init()
{
- basedir = getFile().getParentFile().toPath().toAbsolutePath();
+ basedir = getFile().getParent().toAbsolutePath();
}
public Path getBaseDir()
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java b/jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java
index fccc76209a..862422f94f 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/TextFile.java
@@ -19,10 +19,11 @@
package org.eclipse.jetty.start;
import java.io.BufferedReader;
-import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -36,40 +37,37 @@ import java.util.regex.Pattern;
*/
public class TextFile implements Iterable<String>
{
- private final File file;
+ private final Path file;
private final List<String> lines = new ArrayList<>();
- public TextFile(File file) throws FileNotFoundException, IOException
+ public TextFile(Path file) throws FileNotFoundException, IOException
{
this.file = file;
init();
if (!FS.canReadFile(file))
{
- StartLog.debug("Skipping read of missing file: %s",file.getAbsolutePath());
+ StartLog.debug("Skipping read of missing file: %s",file.toAbsolutePath());
return;
}
- try (FileReader reader = new FileReader(file))
+ try (BufferedReader buf = Files.newBufferedReader(file,StandardCharsets.UTF_8))
{
- try (BufferedReader buf = new BufferedReader(reader))
+ String line;
+ while ((line = buf.readLine()) != null)
{
- String line;
- while ((line = buf.readLine()) != null)
+ if (line.length() == 0)
{
- if (line.length() == 0)
- {
- continue;
- }
-
- if (line.charAt(0) == '#')
- {
- continue;
- }
+ continue;
+ }
- // TODO - bad form calling derived method from base class constructor
- process(line.trim());
+ if (line.charAt(0) == '#')
+ {
+ continue;
}
+
+ // TODO - bad form calling derived method from base class constructor
+ process(line.trim());
}
}
}
@@ -84,7 +82,7 @@ public class TextFile implements Iterable<String>
lines.add(line);
}
- public File getFile()
+ public Path getFile()
{
return file;
}
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
index 36c11743cb..ced1889b5c 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java
@@ -53,7 +53,7 @@ public class ConfigurationAssert
{
File testResourcesDir = MavenTestingUtils.getTestResourcesDir();
File file = MavenTestingUtils.getTestResourceFile(filename);
- TextFile textFile = new TextFile(file);
+ TextFile textFile = new TextFile(file.toPath());
// Validate XMLs (order is important)
List<String> expectedXmls = new ArrayList<>();
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/FSTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/FSTest.java
index e44fb5cbe6..4061851b18 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/FSTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/FSTest.java
@@ -31,21 +31,21 @@ public class FSTest
public void testCanReadDirectory()
{
File targetDir = MavenTestingUtils.getTargetDir();
- Assert.assertTrue("Can read dir: " + targetDir,FS.canReadDirectory(targetDir));
+ Assert.assertTrue("Can read dir: " + targetDir,FS.canReadDirectory(targetDir.toPath()));
}
@Test
public void testCanReadDirectory_NotDir()
{
File bogusFile = MavenTestingUtils.getTestResourceFile("bogus.xml");
- Assert.assertFalse("Can read dir: " + bogusFile,FS.canReadDirectory(bogusFile));
+ Assert.assertFalse("Can read dir: " + bogusFile,FS.canReadDirectory(bogusFile.toPath()));
}
@Test
public void testCanReadFile()
{
File pom = MavenTestingUtils.getProjectFile("pom.xml");
- Assert.assertTrue("Can read file: " + pom,FS.canReadFile(pom));
+ Assert.assertTrue("Can read file: " + pom,FS.canReadFile(pom.toPath()));
}
/**

Back to the top