Skip to content

Instantly share code, notes, and snippets.

@tisseurdetoile
Created November 3, 2017 14:19
Show Gist options
  • Save tisseurdetoile/bd3d9ed86fad5af977a4287f4158ca0f to your computer and use it in GitHub Desktop.
Save tisseurdetoile/bd3d9ed86fad5af977a4287f4158ca0f to your computer and use it in GitHub Desktop.
Java/4/6 stuff
/**
* 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
SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" );
Date date = format.parse( myString );
System.getProperties().put("http.proxyHost", "someProxyURL");
System.getProperties().put("http.proxyPort", "someProxyPort");
System.getProperties().put("http.proxyUser", "someUserName");
System.getProperties().put("http.proxyPassword", "somePassword");
/**
* 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();
/**
* 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