This file contains hidden or 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
import java.io.File; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
class ToAbsoluteFilePath { | |
public static List<File> listFiles(String directoryName) { | |
File directory = new File(directoryName); | |
List<File> resultList = new ArrayList<>(); |
This file contains hidden or 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
class StringUtil { | |
public static void main(String args[]) { | |
} | |
public static boolean isOnlyOneWord(String s) { | |
return (s.length() > 0 && s.split("\\s+").length == 1); | |
} |
This file contains hidden or 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
import java.text.SimpleDateFormat; | |
import java.time.Month; | |
import java.time.format.TextStyle; | |
import java.util.Calendar; | |
import java.util.Date; | |
import java.util.Locale; | |
class DateUtil { | |
public static void main(String args[]) { |
This file contains hidden or 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
import java.nio.file.FileSystems; | |
class ToAbsoluteFilePath { | |
public static void main(String args[]) { | |
System.out.println(toAbsolutePath("C:\\")); | |
} | |
public static String toAbsolutePath(String path) { | |
return FileSystems.getDefault().getPath(path).normalize().toAbsolutePath().toString(); |
This file contains hidden or 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
import java.util.Random; | |
class GenerateRandomString { | |
public static void main(String args[]) { | |
System.out.println(getRandomeStr()); | |
} | |
public static String getRandomeStr() { | |
int leftLimit = 48; // numeral '0' |