the order to get future results is the tasks order. If the later task executes faster than the earlier task, you still need to wait for the earlier task to complete.
new Random().nextInt(min, max+1) return [min, max]
// Java 8 intsize=1, min = 0, max = 10; ThreadLocalRandomrandom= ThreadLocalRandom.current(); intrandomNumber= random.ints(size, min, max + 1).findFirst().getAsInt();
intsize=5, min = 0, max = 10; ThreadLocalRandomrandom= ThreadLocalRandom.current(); int[] randomNumbers = random.ints(size, min, max + 1).toArray();
intsize=5, min = 0, max = 10; Randomrandom=newRandom(); int[] randomNumbers = random.ints(size, min, max + 1).toArray();
// Java 1.7 or later intmin=0, max = 10; ThreadLocalRandomrandom= ThreadLocalRandom.current(); intrandomNum= random.nextInt(min, max + 1);
// Before Java 1.7 intmin=0, max = 10; Randomrandom=newRandom(); intrandomNum= random.nextInt((max - min) + 1) + min;
Math.random() return [0, 1)
Random.nextInt(n) is more efficient than Math.random() * n
Math.random() uses Random.nextDouble() internally. Random.nextDouble() uses Random.next() twice to generate a double that has approximately uniformly distributed bits in its mantissa, so it is uniformly distributed in the range 0 to 1-(2^-53).
Random.nextInt(n) uses Random.next() less than twice on average- it uses it once, and if the value obtained is above the highest multiple of n below MAX_INT it tries again, otherwise is returns the value modulo n (this prevents the values above the highest multiple of n below MAX_INT skewing the distribution), so returning a value which is uniformly distributed in the range 0 to n-1.
matches() - Checks if the regexp matches the complete string.
Stringsource="hello there, I am a Java developer. She is a Web developer."; Patternpattern= Pattern.compile("a (.*?) developer"); Matchermatcher= pattern.matcher(source); System.out.println(matcher.matches()); // false
Stringsource="hello there, I am a Java developer. She is a Web developer."; Patternpattern= Pattern.compile("a (.*?) developer", Pattern.CASE_INSENSITIVE); Matchermatcher= pattern.matcher(source); // find all match strings while (matcher.find()) { System.out.println(matcher.group()); // a Java developer, a Web developer for (inti=1; i < matcher.groupCount(); i++) { System.out.println(matcher.group(i)); // Java, Web } } // reset matcher for reuse matcher.reset(); // only find once if (matcher.find()) { System.out.println(matcher.group()); // a Java developer System.out.println(matcher.group(1)); // Java }
Replace group string
Stringsource="hello there, I am a Java developer. She is a Web developer."; Stringregex="a (.*?) developer"; intgroupToReplace=1; Stringreplacement="Good"; Matchermatcher= Pattern.compile(regex).matcher(source); StringBuilderresult=newStringBuilder(source); intadjust=0; while (matcher.find()) { intstart= matcher.start(groupToReplace); intend= matcher.end(groupToReplace); result.replace(start + adjust, end + adjust, replacement); adjust += replacement.length() - (end - start); } System.out.println(result); //hello there, I am a Good developer. She is a Good developer.
Notice: To avoid a circular dependency between submodules. A circular dependency occurs when a module A depends on another module B, and the module B depends on module A.
Testing in Spring Boot Multi-Modules Maven Project
Gotenberg-Webhook-Url - the callback to use - required
Gotenberg-Webhook-Error-Url - the callback to use if error - required
Gotenberg-Webhook-Method - the HTTP method to use (POST, PATCH, or PUT - default POST).
Gotenberg-Webhook-Error-Method - the HTTP method to use if error (POST, PATCH, or PUT - default POST).
Gotenberg-Webhook-Extra-Http-Headers - the extra HTTP headers to send to both URLs (JSON format).
Common Errors
Error: file name is too long
{"level":"error","ts":1649232587.172472,"logger":"api","msg":"create request context: copy to disk: create local file: open /tmp/9e10e36d-c5a9-4623-9fac-92db4a0d0982/xxx.doc: file name too long","trace":"de0b5ce2-5a99-406e-a61d-4abb65ef0294","remote_ip":"xxx.xxx.xxx.xxx","host":"xxx.xxx.xxx.xxx:3000","uri":"/forms/libreoffice/convert","method":"POST","path":"/forms/libreoffice/convert","referer":"","user_agent":"okhttp/4.9.3","status":500,"latency":13161094736,"latency_human":"13.161094736s","bytes_in":6983097,"bytes_out":21}
Solutions
Decreasing your file name length.
Error: file name contains UTF-8 characters
{"level":"error","ts":1649234692.9638329,"logger":"api","msg":"convert to PDF: unoconv PDF: unix process error: wait for unix process: exit status 6","trace":"28d9a196-10e5-4c7d-af6a-178494f49cd1","remote_ip":"xxx.xxx.xxx.xxx","host":"xxx.xxx.xxx.xxx:3000","uri":"/forms/libreoffice/convert","method":"POST","path":"/forms/libreoffice/convert","referer":"","user_agent":"okhttp/4.9.3","status":500,"latency":130617774,"latency_human":"130.617774ms","bytes_in":11559,"bytes_out":21}
Solutions
Encoding filename by URLEncoder.encode(fileName, "UTF-8").
Host github.com User git Port 22 Hostname github.com IdentityFile "C:\Users\Taogen\.ssh\id_ed25519" TCPKeepAlive yes IdentitiesOnly yes
Host ssh.github.com User git Port 443 Hostname ssh.github.com IdentityFile "C:\Users\Taogen\.ssh\id_ed25519" TCPKeepAlive yes IdentitiesOnly yes
You can put the ProxyCommand ... under a specific Host xxx.xxx.xxx like this if you need to access multiple git hosting sites but set an SSH proxy for only one site.