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.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class RFC3986 { | |
private static final Pattern ptn = Pattern.compile("%[A-Fa-f0-9]{2}"); | |
private static final String character = "字元值["; | |
private static final String overRange = "]超出範圍"; | |
private static final String string = "字串["; | |
private static final String containInvalidEncode = "]含有無效編碼"; |
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.util.*; | |
public class Utilities { | |
private static final Pattern pDquote = Pattern.compile("\""); | |
private static final Pattern pSquote = Pattern.compile("'"); | |
private static final Pattern pBackSlash = Pattern.compile("\\\\"); | |
private static final Pattern pNewline = Pattern.compile("[\n\r]+"); | |
public static String alertInner(String msg) { | |
return msg == null || msg.trim().isEmpty() ? "" : pNewline.matcher( | |
pSquote.matcher(pDquote.matcher(pBackSlash.matcher(msg).replaceAll("\\\\\\\\")).replaceAll(""")).replaceAll("\\\\'")).replaceAll("\\\\r\\\\n"); |
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 DownloadAction extends Action { | |
public void downloadXls(HttpServletRequest request,HttpServletResponse response){ | |
WritableWorkbook workbook = Workbook.createWorkbook(response.getOutputStream()); | |
//....Genrate Xls | |
response.setHeader("Expires", "0"); | |
response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); | |
response.setHeader("Pragma", "public"); | |
response.setContentType("application/vnd.ms-excel"); | |
response.setCharacterEncoding("UTF-8"); | |
//starts with "attachment;" means force download,otherwise "inline;" instaed means view in browser |
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.math.BigInteger; | |
import java.util.UUID; | |
/** Code from | |
* https://github.com/cchigoriwa/jaxcsd/blob/master/jaxcsd-api/src/main/java/zw/co/hitrac/jaxcsd/api/util/UUIDBasedOID.java | |
*/ | |
public class UUIDBasedOID { | |
protected static final String OID_PREFIX = "2.25"; // {joint-iso-itu-t uuid(25) <uuid-single-integer-value>} | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.osgeo.proj4j.CRSFactory; | |
import org.osgeo.proj4j.CoordinateReferenceSystem; | |
import org.osgeo.proj4j.CoordinateTransform; | |
import org.osgeo.proj4j.CoordinateTransformFactory; | |
import org.osgeo.proj4j.ProjCoordinate; | |
public class Proj4j { | |
/** | |
* https://search.maven.org/search?q=a:proj4j 找出proj4j轉案 | |
* http://www.sunriver.com.tw/taiwanmap/grid_tm2_convert.php#a03 線上轉換(參考範本) |
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.InputStream; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardOpenOption; | |
import javax.sound.sampled.AudioFormat; |
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.util.regex.Pattern; | |
/** | |
* @author Kent Yeh | |
*/ | |
public class ZhBigNum { | |
public static final Pattern ZEROP = Pattern.compile("\\x{96F6}{2,}"); | |
public static void main(String[] args) { |
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.awt.image.BufferedImage; | |
import java.awt.Image; | |
import java.io.IOException; | |
import java.io.OutputStream; | |
import javax.imageio.ImageIO; | |
public class ResizeImage { | |
public static void resize(BufferedImage bufferedImage, int maxEdge, OutputStream os) throws IOException { | |
int w = bufferedImage.getWidth(); |
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 static boolean isValidIDorRCNumber(String ID) { | |
if (ID == null || ID.trim().isEmpty() || !ID.matches("[A-Za-z][A-Da-d1289]\\d{8}")) { | |
return false; | |
} | |
String head = "ABCDEFGHJKLMNPQRSTUVXYWZIO"; | |
char[] id = ID.toUpperCase().toCharArray(); | |
int chksum = (head.indexOf(id[0]) + 10) / 10 | |
+ (head.indexOf(id[0]) + 10) % 10 * 9 % 10; | |
chksum += (id[1] > '@' && id[1] < 'E') ? ((head.indexOf(id[1]) + 10) % 10) * 8 % 10 | |
: (id[1] - 48) * 8 % 10; |
OlderNewer