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
Path path = Paths.get("D:\\Directory"); | |
WatchService watchService = path.getFileSystem().newWatchService(); | |
path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE); | |
System.out.println("Watching..."); | |
for (;;) | |
{ | |
WatchKey wk = watchService.take(); | |
wk.pollEvents().forEach(we -> System.out.println(we.context() + ", " + we.kind() + ", " + we.count())); |
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
package test; | |
import java.io.IOException; | |
import java.util.function.Predicate; | |
public class AnyThrowableMatchesPredicateInThrowableChain | |
{ | |
public static void main(String[] args) throws IOException | |
{ | |
Throwable throwable = new Throwable("sdsdf"); |
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
var comparisonFunctionByOperator = (function () | |
{ | |
var hash = { | |
"<" : (left, right) => left < right, | |
"<=" : (left, right) => left <= right, | |
">" : (left, right) => left > right, | |
">=" : (left, right) => left >= right, | |
"===": (left, right) => left === right, | |
"!==": (left, right) => left !== right, | |
"==" : (left, right) => left == right, |
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
if (typeof $ARG === "undefined" || $ARG.length !== 2) | |
print("Usage: jjs -scripting --language=es6 test.js -- arg1 arg2"); | |
else | |
doSomething.apply(null, $ARG); | |
function doSomething(first, second) | |
{ | |
print("first: " + first + ", second: " + second); | |
for (let i = 0; i < 2; i++) |
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
public class JaxbPartialObjectParser | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
String xmlStr = "<root><student><name>Raju</name></student></root>"; | |
// Assuming Student class is JAXB generated | |
Iterator<Student> it = extractPartialObjects(new StringReader(xmlStr), QName.valueOf("student"), Student.class); | |
while (it.hasNext()) |
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
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Task Tracker</title> | |
<!-- Version: 0.5 --> | |
<style> | |
table { | |
border-collapse: collapse; | |
} |
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
package raju.javautils.xml; | |
import java.io.File; | |
import javax.xml.transform.stream.StreamSource; | |
import javax.xml.validation.Schema; | |
import javax.xml.validation.SchemaFactory; | |
import javax.xml.validation.Validator; | |
import org.xml.sax.SAXException; |
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
package raju.javautil; | |
import java.io.BufferedReader; | |
import java.io.ByteArrayOutputStream; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.UnsupportedEncodingException; | |
import java.nio.charset.Charset; |
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.ArrayList; | |
import java.util.List; | |
public final class CharEscaper | |
{ | |
private final char escapeChar, escapeForEscapeChar; | |
public CharEscaper(char escapeChar, char escapeForEscapeChar) | |
{ | |
if (escapeChar == escapeForEscapeChar) |
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
package raju.fileutils; | |
import java.io.IOException; | |
import java.nio.file.FileSystems; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.PathMatcher; | |
import java.nio.file.Paths; | |
import java.util.ArrayList; | |
import java.util.Arrays; |