Created
May 9, 2012 17:47
-
-
Save dtgay/2647212 to your computer and use it in GitHub Desktop.
Java won't append a slash if missing from a String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tests the duplicate file finder | |
* For RIT 4002-219 | |
* Author: David Gay | |
* Spring 2012 | |
* CODE WRITTEN FOR USE ON A LINUX FILESYSTEM | |
*/ | |
public class TestDups | |
{ | |
/** | |
* Main | |
* Program entry point | |
* @param args[0] the starting directory | |
*/ | |
public static void main(String[] args) | |
{ | |
String startingDir; | |
try | |
{ | |
startingDir = args[0]; | |
System.out.println("last char: " + startingDir.charAt(startingDir.length() - 1)); | |
if (startingDir.charAt(startingDir.length() - 1) != '/') | |
{ | |
// If the user did not include a closing slash (/), append it | |
startingDir.concat("/"); | |
} | |
} | |
catch (ArrayIndexOutOfBoundsException aioobe) | |
{ | |
// If no argument is given, set a default starting dir | |
startingDir = "~/."; | |
} | |
System.out.println("Duplicate File Finder - by David Gay"); | |
System.out.println("Find duplicates. Processing: " + startingDir); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment