๐ปTech/โJava18 [Java] ํด๋ํฐ ๋ฒํธ ๋ง์คํน ์ฝ๋ ํด๋ํฐ ๋ฒํธ๋ฅผ asterisk(*)๋ก ์ํธํํ๋ ์ฝ๋์ ๋๋ค. /** * encrypt number in text * * maskingCallNumber * * @param str * @return String */ public static String maskingCallNumber(String str){ String replaceString = str; String matchedStr =""; String pattern ="(\\d{2,3})-?(\\d{3,4})-?(\\d{3,4})"; Matcher matcher = Pattern.compile(pattern).matcher(str); if(matcher.find()){ StringBuffer br = new StringBuffer(); for(in.. 2019. 6. 12. [Java] ์ด๋ฆ ๋ง์คํน ์ฝ๋ ์ด๋ฆ์ asterisk(*)๋ก ์ํธํํ๋ ์ฝ๋์ ๋๋ค. /** * maskingName * * @param str * @return String */ public static String maskingName(String str) { String replaceString = str; String pattern = ""; if(str.length() == 2) { pattern = "^(.)(.+)$"; } else { pattern = "^(.)(.+)(.)$"; } Matcher matcher = Pattern.compile(pattern).matcher(str); if(matcher.matches()) { replaceString = ""; for(int i=1;i 2019. 6. 12. [Java] ๋ ์ง ๋ํ๊ธฐ, ๋นผ๊ธฐ ์ฝ๋ /** * ๋ ์ง ๋ํ๊ธฐ * * @param dataeFormat yyyyMMdd .. * @param strDate 20190612 .. * @param dateUnit DATE or HOUR * @param addDate 1, -1 ... * @return */ public static String dateAdd(String dataeFormat, String strDate, String dateUnit, int addDate) { DateFormat dateFormat = null; Date date = new Date(); try { dateFormat = new SimpleDateFormat(dataeFormat); date = dateFormat.parse(strDate); } catch (Pa.. 2019. 6. 12. [Java] ๋ฆฌ๋ ์ค ๋ช ๋ น์ด ์คํ ์ฝ๋ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ์ ๋๋ค. โพ ProcessBuilder ๋ฐฉ์ ProcessBuilder๋ ๋ช ๋ น์ด์ ์ธ์๋ฅผ ์ง์ ์ง์ ํ๋ฏ๋ก ์ ๋ช ๋ น์ด๋ ํน์ ๋ฌธ์(ex: |, >, < ) ์ฌ์ฉ์ด ๋ถ๊ฐ String command = "ls"; new ProcessBuilder("/bin/bash", "-c", command).start(); โพ Runtime.exec() ๋ฐฉ์ /** * cmd ๋ช ๋ น์ด ์คํ * * @param cmd */ public static boolean executeCmd(String cmd) { Process process = null; Runtime runtime = Runtime.getRuntime(); StringBuffer successOutput = new StringBuffer(); Stri.. 2019. 6. 11. Java Date ์ ๊ท์ ์๋ฐ date(๋ ์ง) ํฌ๋งท ๋ณ ์ ๊ท์์ ๋๋ค. public static final String YYYYMMDD = "(19|20)\\d{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])"; public static final String YYYYMMDDHH = "(19|20)\\d{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])(0[0-9]|1[0-9]|2[0-3])"; public static final String YYYYMMDDHHMI = "(19|20)\\d{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])(0[0-9]|1[0-9]|2[0-3])([0-5][0-9])"; public static final String YY.. 2019. 5. 31. [Java] TarArchiveInputStream error detected parsing the header ๐ซ ERROR java.io.IOException: Error detected parsing the header FileInputStream fin = null; BufferedInputStream bis = null; GzipCompressorInputStream gzIn = null; TarArchiveInputStream tarIn = null; InputStreamReader is = null; BufferedReader br = null; fin = new FileInputStream(); bis = new BufferedInputStream(fin); tarIn = new TarArchiveInputStream(bis); is = new InputStreamReader(tarIn, "UTF-8.. 2016. 7. 11. [Java] ๋ฌธ์์ด์์ date ํน์ ํจํด ๊ฐ์ ธ์ค๊ธฐ ๐จ๐ป ๋ฌธ์์ด์์ ํน์ ํจํด์ date ๊ฒ์ถํ๋ ๋ฐฉ๋ฒ ๋ฌธ์์ด์์ ์ ๊ท์์ ์ด์ฉํ์ฌ Date yyMMdd ํํ์ ํจํด ๊ฒ์ถ String yyMMdd = "(19|20)\\d{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])"; String date = "20160620date"; String src = ""; Pattern pattern = Pattern.compile(yyMMdd); Matcher matcher = pattern.matcher(date); while(matcher.find()){ src = matcher.group(); } System.out.println("src: " + src); ๊ฒฐ๊ณผ ๊ฐ : 20160620 2016. 6. 20. [Java] ๊ณ์ฐ๊ธฐ ์์ค (๊ดํธ, ์ฌ์น์ฐ์ฐ ์ฐ์ ์์) ๊ดํธ, ์ฌ์น์ฐ์ฐ ์ฐ์ ์์ ์ฒ๋ฆฌํ๋ ๊ณ์ฐ๊ธฐ ์์ค ๊ณต์ ํฉ๋๋ค. ํ์ํ๊ธฐ๋ฒ๊ณผ Stack ๊ธฐ๋ฐ์ผ๋ก ๊ตฌํํ์ต๋๋ค. ์๋ฒฝํ๊ฒ ์์ธ์ฒ๋ฆฌ ๋ ๋ถ๋ถ์ด ์๋๋ผ ์ฐธ๊ณ ํ์๋ฉด ์ข๊ฒ ์ต๋๋ค. package test; import java.util.ArrayList; import java.util.Stack; /** * ๊ณ์ฐ ์๋น์ค * * @author * @version * @since * @created 2015. 1. 12. */ public class CalculatorService { public static void main(String[] args) { String result = getCalculate("(10 + 20) * 10"); System.out.println(result); } /** * ๊ณ์ฐ์ฒ๋ฆฌ */ pr.. 2015. 9. 16. ์ด์ 1 2 3 ๋ค์