Created
November 3, 2017 14:19
-
-
Save tisseurdetoile/bd3d9ed86fad5af977a4287f4158ca0f to your computer and use it in GitHub Desktop.
Java/4/6 stuff
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
/** | |
* Recherche dans une liste sans tenir compte de la case | |
*/ | |
List<String> bigList = = Arrays.asList("Chien", "Chat"); | |
String srchItem = "chien"; | |
Set<String> set= new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); | |
set.addAll(bigList); | |
boolean test = set.contains(srchItem) // true |
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
SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" ); | |
Date date = format.parse( myString ); |
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
System.getProperties().put("http.proxyHost", "someProxyURL"); | |
System.getProperties().put("http.proxyPort", "someProxyPort"); | |
System.getProperties().put("http.proxyUser", "someUserName"); | |
System.getProperties().put("http.proxyPassword", "somePassword"); |
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
/** | |
* Singleton Class Sample. | |
*/ | |
public class SimpleSingleton { | |
private static SimpleSingleton singleInstance = new SimpleSingleton(); | |
//Marking default constructor private | |
//to avoid direct instantiation. | |
private SimpleSingleton() { | |
} | |
//Get instance for class SimpleSingleton | |
public static SimpleSingleton getInstance() { | |
return singleInstance; | |
} | |
} | |
public enum SimpleEnumSingleton { | |
INSTANCE; | |
public void doSomething() { | |
} | |
} | |
//Call the method from Singleton: | |
// SimpleEnumSingleton.INSTANCE.doSomething(); |
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
/** | |
* recupère le chemin en cours. | |
*/ | |
URL location = NewEmptyJUnitTest.class.getProtectionDomain().getCodeSource().getLocation(); | |
System.out.println(location.getFile()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment