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.nio.ByteBuffer; | |
import java.nio.charset.CharacterCodingException; | |
import java.nio.charset.Charset; | |
import java.nio.charset.CharsetDecoder; | |
import java.nio.charset.CodingErrorAction; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class UTF8PerJavaVersion { | |
public static void main(String[] args) throws CharacterCodingException { |
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
/* | |
abcxyzABCDEGPWXXYZ0(12_{@|.)+$}\/^$*!- | |
======A==========Z===================- | |
"A-Z": /[^\QA-Z\E]/ | |
abcxyzABCDEGPWXXYZ0(12_{@|.)+$}\/^$*!- | |
==========================.=========== | |
".": /[^\Q.\E]/ |
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
#include <climits> | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main() { | |
int input = 0; | |
cin >> input; |
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 com.google.gson.Gson; | |
import java.util.LinkedHashMap; | |
import java.util.LinkedList; | |
import java.util.Map; | |
public class GsonTest { | |
public static void main(String[] args) { | |
LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(); |
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.io.BufferedWriter; | |
import java.io.IOException; | |
import java.nio.charset.Charset; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardOpenOption; | |
public class Symbols { | |
public static void main(String[] args) throws IOException { |
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.nio.charset.Charset; | |
public class BinString { | |
public static void main(String[] args) { | |
byte[] array = new byte[3]; | |
array[0] = (byte)0x9c; | |
array[1] = (byte)0xff; | |
array[2] = (byte)0xc9; | |
String str1 = new String(array, Charset.forName("ISO-8859-1")); | |
for (int i = 0; i < str1.length(); ++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 JavaTimeTest { | |
public static void main(String[] args) { | |
OffsetDateTime date1 = OffsetDateTime.parse("2012-01-01T02:03:04+01:00"); | |
OffsetDateTime date2 = OffsetDateTime.parse("2013-02-01T02:03:04+01:00"); | |
Period period1d = Period.parse("P1D"); | |
Period period1m = Period.parse("P1M"); | |
Period period1m1d = Period.parse("P1M"); | |
Period period1y1d = Period.parse("P30D"); | |
OffsetDateTime date1_1m1d = date1.plus(period1m1d); | |
System.out.println(date1_1m1d); |
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.HashMap; | |
import java.util.Map; | |
public class InitializationOnDemand { | |
private static class LazyHolder { | |
private static final Map<String, String> instance = create(); | |
static { | |
System.out.println("static{}"); | |
instance.put("foo", "bar"); | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.github.dmikurube</groupId> | |
<artifactId>guice-cdi-test</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>war</packaging> |
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 org.w3c.dom.Document; | |
import org.w3c.dom.Element; | |
import javax.xml.bind.annotation.adapters.XmlAdapter; | |
import javax.xml.parsers.DocumentBuilder; | |
import javax.xml.parsers.DocumentBuilderFactory; | |
// XmlAdapter<Object,*> receives XML DOM nodes in org.w3c.dom.Element. | |
public class MyXmlAdapter extends XmlAdapter<Object, TargetClass> { |