๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ’ป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.