Şöyle yaparız
WatchKey key = ...;for (final WatchEvent<?> event : key.pollEvents()) {final Path changed = monitoringDirectory.resolve((Path) event.context());if (event.kind() == ENTRY_MODIFY && changed.equals(file)) {...}}
WatchKey key = ...;for (final WatchEvent<?> event : key.pollEvents()) {final Path changed = monitoringDirectory.resolve((Path) event.context());if (event.kind() == ENTRY_MODIFY && changed.equals(file)) {...}}
Kotlin has made our life very easy by providing features like extension functions, nullability check and much more. One such kind of really helpful feature is Scope functions. Once you understand what scope functions are, you will not able to resist yourself from using them.Scope functions are nothing but the functions which define to the scope of the calling object. We can apply operations on that object within that scope and return the object itself from that scope function or we can even return the result of operation or operations from the scope function.There are a few scope functions- let- with- run- apply- also
Extension Functionrun has two variants, one is an extension function to Template class and another one is not an extension function to Template class.
class Employee {var firstName: String? = nullvar age: Int = 0}val employee: Employee? = Employee()employee?.firstName = "Suneet"employee?.age = 27employee?.run {println(age)}
val alphaNumeric = run {val digits = "0-9" val aplhabets = "A-Za-z" Regex("[$digits$aplhabets]+") } for (match in alphaNumeric.findAll("+1234 -FFFF I-am?-a!string?!")) { println(match.value) } //this will print 1234 FFFF I am a string
Micronaut provides two ways of creating HTTP clients:- A declarative HTTP Client- A programmatic HTTP Client
@Validatedpublic interface PetOperations {@PostSingle<Pet> save(@NotBlank String name, @Min(1L) int age);}@Client("/pets")public interface PetClient extends PetOperations {@OverrideSingle<Pet> save(String name, int age);}PetClient client = applicationContext.getBean(PetOperations.class);Single<Pet> pet = client.save("Hoppie", 1));
public static String format(String format, Object... args)
public static String format(Locale l, String format, Object... args) {%<index$><flags><width><.precision><conversion>
String name = "Tandrew";
int age = 16;
String formattedString = String.format(Locale.US, "My name is %s and I am %d years old",
name, age);
// notice the format specifiers %s and %d
System.out.println(formattedString);
// Output: My name is Tandrew and I am 16 years old<index$> is an optional positive integer that corresponds to an argument in the argument list. This index starts at 1 (i.e., the first argument in the argument list is indexed as 1). Therefore, the first argument in the argument list can be addressed using 1$, the second argument can be addressed using 2$, and so on. For example, we can format a String — which has a conversion of s— that corresponds to the second argument in our argument list using the following format specifier:
String.format("The hex value of %d is 0x%1$h",8756);//"The hex value of 8756 is 0x2234"
- Left-justifies the results.# Uses an alternative form.+ Always includes a sign.(space) Add leading space for positive values.0 Zero-pads the result., Includes locale-specific grouping separators.( Encloses negative numbers in parenthesis.
String formattedString1 = String.format("%10s", "name"); // Result: "name "String formattedString2 = String.format("%-10s", "name"); // Result: " name"
BigInteger n = ...;
String md5h = String.format("%032x",n);General:Maximum number of characters displayed; if the supplied argument results in more characters than the supplied precision, the resulting string is truncated to the correct number of characters. For example, supplying Justin as an argument to the format specifier %.1s result in J.Floating point (e, E, and f):Number of digits after the decimal place. For example, a format specifier of %.1f with an argument of 1.2345 results in 1.2.Floating point (g, G, a and A):Number of digits in the magnitude after rounding.
%b, B : true, false, TRUE, FALSE%h, H : fff03,6199ec4,6199EC4%s, S : foo ,bar, BAR%c, C : c, f ,F%d : 10,5347%o : 2,151%x, X : ff4,e56d2,E56D2%e, E : 1.114313e+09,1.682340e-08,1.682340E-08%f : 4.562340, 1245.643876%g, G : 128636, 8.12935e+16,3546.50,8.12935E+16%a, A : 0x1.63c774a3d70a4p19, 0x1.187ff0337c5abp-26, 0X1.8D7025536252DP45
The boolean result as a string (e.g., true or false) if the supplied argument is a Boolean. false if the supplied argument is null and true for all other arguments. If B is used, the resulting boolean value is capitalized (e.g., TRUE or FALSE).
The hexadecimal value of the supplied argument, arg, by applying the expression Integer.toHexString(arg.hashCode()). Note that the result does not include a 0x prefix. If H is used, the resulting alphabetic hexadecimal characters are capitalized.
The provided argument as a string (by invoking Object.toString). If the supplied argument is a Formattable object, the string is obtained by invoking Formattable.formatTo. If S is supplied, the supplied string is capitalized.
int a = ...;
int b = ...;
int c = ...;
return String.format("%s-%s-%s", a, b, c);The Unicode character. If a String object is supplied, an IllegalFormatConversionException is thrown. If C is used, the supplied character is capitalized.
String.format("%011d", 4366)Çıktı olarak şunu alırız00000004366The hexadecimal integer. Note that the result does not include a 0x prefix. This specifier should be preferred over h when supplying an integer. If X is used, the resulting alphabetic hexadecimal characters are capitalized.
int a = ...;
System.out.println( String.format("%X", a) );The value in scientific notation. If E is used, the exponent symbol (e) is capitalized (i.e., E).
Use %.4f to perform the rounding you want. This format specifier indicates a floating point value with 4 digits after the decimal place. Half-up rounding is used for this, meaning that if the last digit to be considered is greater than or equal to five, it will round up and any other cases will result in rounding down.Örnek
String.format("%.2f", 62.1232131342);Floating Point In Scientific Notation Or Decimal Format- %gThe value in scientific notation or decimal format, depending on the result after rounding. If G is used, the exponent symbol (e) is capitalized (i.e., E).
The %g format specifier is used to indicate how many significant digits in scientific notation are displayed. Leading zeroes are not significant, so they are skipped.Örnek
String.format("%.4g", 0.1234712)ÖrnekString.format("%.4g", 0.000987654321)
The value in scientific notation, where the significand is a hexadecimal floating point value, and the power follows a p delimiter. If A is used, the resulting alphabetic hexadecimal characters are capitalized and the p delimiter is capitalized (i.e., P).
Quarkus, on the other hand, is developed and backed by RedHat, Inc., which is a well-known company in the programming world.Quarkus Altta Ne Kullanır
Quarkus depends heavily on the Vert.x toolkit and MicroProfile project. The Eclipse Foundation maintains both.
README.mdpom.xmlbuild.gradlesrc/main/dockersrc/main/javasrc/main/resourcessrc/main/resources/application.propertiessrc/main/resources/application.ymlsrc/main/resources/application.yamlsrc/main/resources/META-INF/resourcessrc/test/java
./mvnw quarkus:dev./gradlew quarkusDev
./mvnw package -Pnative./gradlew build -Dquarkus.package.type=native
... Quarkus uses SmallRye reactive library
@Path("/application-info")@Produces(MediaType.APPLICATION_JSON)@Consumes(MediaType.APPLICATION_JSON)class ApplicationInfoResource(
@Inject private val applicationInfoService: ApplicationInfoService) {@GETfun get(@QueryParam("request-to") requestTo: String?): Response =Response.ok(applicationInfoService.get(requestTo)).build()@GET@Path("/logo")@Produces("image/png")fun logo(): Response =Response.ok(applicationInfoService.getLogo()).build()}
quarkus:
datasource:
customers:
db-kind: h2
jdbc: false
reactive:
url: h2:file:~/testdb
max-size: 20activeMQ start
http://localhost:8161/admin/Menülerde Queue ve Topic linklerini kullanarak kuyruklara bakılabilir.
In spite of HornetQ's incredible speed, however, it failed to surpass its biggest competitor. Near the end of 2014, the codebase for HornetQ was donated to the Apache ActiveMQ community. Today, it exists as an Active MQ subproject called Artemis.