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
import org.trie4j.doublearray.DoubleArray; | |
import org.trie4j.louds.LOUDSTrie; | |
import org.trie4j.patricia.simple.PatriciaTrie; | |
public class Sample { | |
public static void main(String[] args) throws Exception{ | |
PatriciaTrie pat = new PatriciaTrie(); | |
pat.insert("Hello"); | |
pat.insert("World"); | |
pat.insert("Wonder"); |
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
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import java.io.ObjectInputStream; | |
import java.io.ObjectOutputStream; | |
import java.io.ObjectStreamClass; | |
import java.net.URL; | |
import java.net.URLClassLoader; | |
import java.nio.file.Paths; | |
import java.util.HashMap; |
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
package seimei; | |
import jp.go.nict.langrid.commons.util.Pair; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.Arrays; |
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
public class MsgPackTest { | |
public static void main(String[] args) throws Exception { | |
MessagePack msgpack = new MessagePack(); | |
List<String> lines = Arrays.asList("hello", "world"); | |
byte[] bytes = msgpack.write(lines); | |
msgpack.register(List.class, new ListTemplate(ValueTemplate.getInstance())); | |
for(Value v: (List<Value>)msgpack.read(bytes, List.class)){ | |
System.out.println(new String(v.asRawValue().getByteArray(), "UTF-8")); | |
} | |
} |
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
Arrays.stream(new File("lib").listFiles(f -> f.getName().endsWith(".jar"))) | |
.map(f -> f.getAbsolutePath()) | |
.reduce(".", (l, r) -> l + File.pathSeparator + r) |
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
URL[] paths = CollectionUtil.stream(Arrays.asList(cp.split(File.pathSeparator))) | |
.map(new Function<String, URL>() { | |
public URL apply(String value) { | |
try { | |
return new File(value).toURI().toURL(); | |
} catch (MalformedURLException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
}) |
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
public class LZEnd { | |
static class Phrase{ | |
public Phrase() { | |
} | |
public Phrase(int phraseNum, int ref, int len, char nonMatchedChar) { | |
this.phraseNum = phraseNum; | |
this.ref = ref; | |
this.len = len; | |
this.nonMatchedChar = nonMatchedChar; | |
} |
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
package scalatest; | |
import java.io.File; | |
import scala.tools.nsc.Settings; | |
import scala.tools.nsc.interpreter.IMain; | |
import scala.tools.nsc.interpreter.NamedParamClass; | |
public class ScalaInvoke { | |
public static void main(String[] args) throws Exception{ |
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
/* | |
* tp は Executors.newCachedThreadPool 等を使って生成 | |
*/ | |
// Rhino(JavaScript) | |
tp.submit(new Callable({call: function(){ return 1;}})); | |
// Groovy | |
tp.submit({1} as Callable) |
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
import kawa.standard.Scheme; | |
public class InvokeJavaFromScheme { | |
public static void main(String[] args) throws Throwable{ | |
Scheme s = Scheme.getInstance(); | |
// objにRunnableを実装した匿名クラスのインスタンスを設定。 | |
// runメソッドはRunnableインタフェースのメソッドだから、問題なく呼べるはず。 | |
s.define("obj", new Runnable(){ | |
public void run() { | |
System.out.println("hello"); |