Intro
๋์ ์ฝ๋์ ์ฃผ์์ ๋ฌ์ง๋ง๋ผ. ์๋ก ์ง๋ผ. : ๋ธ๋ผ์ด์ธ W. ์ปค๋ํจ, P.J. ํ๋ผ์ฐ๊ฑฐ
์ฃผ์์ ํ์์ ์ด๋ค. ํ๋ก๊ทธ๋๋ฐ ์ธ์ด ์์ฒด๊ฐ ํํ๋ ฅ์ด ํ๋ถํ๋ค๋ฉด, ํน์ ์ฐ๋ฆฌ๊ฐ ์น๋ฐํ๊ฒ ์๋๋ฅผ ์ ํํํ๋ค๋ฉด ์ฃผ์์ ์ ํ ํ์ํ์ง ์๋ค. ์ฃผ์ ์์ด๋ ์์ ์ ํํํ ๋ฐฉ๋ฒ์ ์ฐพ์ง ๋ชปํด ํ ์ ์์ด ์ฃผ์์ ์ฌ์ฉํ๋ค. ๊ทธ๋์ ์ฃผ์์ ๋ฐ๊ฒจ ๋ง์ ์๋์ด ์๋๋ค.
์ฃผ์์ ๋ฌด์ํ๋ ์ด์ ๊ฐ ๋ฌด์์ด๋๊ณ ? ์ฃผ์์ด ์ค๋๋ ์๋ก ์ฝ๋์์ ๋ฉ์ด์ ธ์ ๊ฑฐ์ง๋ง์ ํ๊ฒ ๋ ๊ฐ๋ฅ์ฑ์ด ์ปค์ง๊ธฐ ๋๋ฌธ์ด๋ค. ์ฝ๋๋ ์ ์ง๋ณด์๋ฅผ ํด๋, ์ฃผ์์ ๊ณ์ ์ ์ง๋ณด์ํ๊ธฐ๋ ํ์ค์ ์ผ๋ก ๋ถ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ด๋ค.
์ฃผ์์ ๋์ ์ฝ๋๋ฅผ ๋ณด์ํ์ง ๋ชปํ๋ค
์ฃผ์์ ์ถ๊ฐํ๋ ์ผ๋ฐ์ ์ธ ์ด์ ๋ ์ฝ๋ ํ์ง์ด ๋๋น ์์ด๋ค. ๊น๋ํ๊ณ ์ฃผ์์ด ๊ฑฐ์ ์๋ ์ฝ๋๊ฐ, ๋ณต์กํ๊ณ ์ด์์ ํ๋ฉฐ ์ฃผ์์ด ๋ง์ด ๋ฌ๋ฆฐ ์ฝ๋๋ณด๋ค ํจ์ฌ ์ข๋ค. ์ฃผ์์ผ๋ก ์ค๋ช ํ๋ ค ์ ์ฐ๋ ๋์ ์ ๊ทธ ๋์ฅํ์ ๊นจ๋์ด ์น์ฐ๋ ๋ฐ ์๊ฐ์ ๋ณด๋ด๋ผ!
์ฝ๋๋ก ์๋๋ฅผ ํํํ๋ผ!
// ์ง์์๊ฒ ๋ณต์ง ํํ์ ๋ฐ์ ์๊ฒฉ์ด ์๋์ง ๊ฒ์ฌํ๋ค.
if ((emplotee.flags & HOURLY_FLAG) && (employee.age > 65)
if (employee.isEligibleForFullBenefits())
์ด๋ค ์ฝ๋๊ฐ ๋์๊ฐ? ์ฃผ์๋ ํ์์์ด ์๋๊ฐ ์ถฉ๋ถํ ํํ๋์๋ค.
์ข์ ์ฃผ์
๊ธ์ ๊ฐ์ ํ๋ ์ฃผ์์ ์ฐพ์๋ณด์.
๋ฒ์ ์ธ ์ฃผ์
// Copyright (C) 2003, 2004, 2005 by Object Montor, Inc. All right reserved.
// GNU General Public License
์ ์๊ถ ์ ๋ณด, ์์ ๊ถ ์ ๋ณด, ๊ณ์ฝ ์กฐ๊ฑด, ํ์ค ๋ผ์ด์ผ์ค, ์ธ๋ถ ๋ฌธ์๋ฅผ ์ ๋๋ค.
์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ์ฃผ์
// ํ
์คํธ ์ค์ธ Responder ์ธ์คํด์ค๋ฅผ ๋ฐํ
protected abstract Responder responderInstance();
protected abstract Responder responderBeingTested(); // ์ด๋ ๊ฒ ํ๋ฉด ์ฃผ์์ ์์จ ์ ์๋ค.
๋ค์๊ณผ ๊ฐ์ ์ฃผ์์ ๋ณด๋ค ์๋ฏธ์๋ค๊ณ ํ ์ ์๋ค.
// kk:mm:ss EEE, MMM dd, yyyy ํ์์ด๋ค.
Pattern timeMatcher = Pattern.compile("\\d*:\\d*\\d* \\w*, \\w*, \\d*, \\d*");
์๋๋ฅผ ์ค๋ช ํ๋ ์ฃผ์
public int compareTo(Object o) {
if (o instanceof WikiPagePath) {
WikiPagePath p = (WikiPagePath) o;
String compressedName = StringUtil.join(names, "");
String compressedArgumentName = StringUtil.join(p.names, "");
return compressedName.compareTo(compressedArgumentName);
}
return 1; // ์ค๋ฅธ์ชฝ ์ ํ์ด๋ฏ๋ก ์ ๋ ฌ ์์๊ฐ ๋ ๋๋ค.
}
// ์ค๋ ๋๋ฅผ ๋๋ ์์ฑํ๋ ๋ฐฉ๋ฒ์ผ๋ก ์ด๋ป๊ฒ๋ ๊ฒฝ์ ์กฐ๊ฑด์ ๋ง๋ค๋ ค ์๋ํ๋ค.
for (int i = 0; i > 2500; i++) {
WidgetBuilderThread widgetBuilderThread =
new WidgetBuilderThread(widgetBuilder, text, parent, failFlag);
Thread thread = new Thread(widgetBuilderThread);
thread.start();
}
๋๋๋ก ์ฃผ์์ ๊ตฌํ์ ์ดํดํ๊ฒ ๋์์ฃผ๋ ์ ์ ๋์ด ๊ฒฐ์ ์ ๊น๋ฆฐ ์๋๊น์ง ์ค๋ช ํ๋ค. ๋ฌธ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์๋ ์ฌ๋ฌ๊ฐ์ง๊ฐ ์์ ์ ์์ผ๋, ํด๋น ์ฝ๋๋ฅผ ์์ฑํ ์๋์์ฒด๋ฅผ ์ ์ด๋์ผ๋ก์ ์ฝ๋๋ฅผ ์ฝ๋ ์ฌ๋์ด ํ์ ํ ์ ์๋๋ก ํ๋ค.
์๋ฏธ๋ฅผ ๋ช ๋ฃํ๊ฒ ๋ฐํ๋ ์ฃผ์
public void testCompareTo() throws Exception {
WikiPagePath a = PathParser.parse("PageA");
WikiPagePath ab = PathParser.parse("PageA.PageB");
WikiPagePath b = PathParser.parse("PageB");
WikiPagePath ba = PathParser.parse("PageB.PageA");
WikiPagePath aa = PathParser.parse("PageA.PageA");
WikiPagePath bb = PathParser.parse("PageB.PageB");
assertTrue(a.compareTo(a) == 0); // a == a
assertTrue(a.compareTo(b) != 0); // a != b
assertTrue(ab.compareTo(ab) == 0); // ab == ab
assertTrue(a.compareTo(b) == -1); // a < b
assertTrue(aa.compareTo(ab) == -1); // aa < ab
assertTrue(ba.compareTo(bb) == -1); // ba < bb
assertTrue(b.compareTo(a) == 1); // b > a
assertTrue(ab.compareTo(aa) == 1); // ab > aa
assertTrue(bb.compareTo(ba) == 1); // bb > ba
}
์์ ์ฝ๋๋ฅผ ๋ณด๋ฉด, ์ด๋ค ๊ฒ์ ๊ฒ์ฆํ๋์ง ํ์ ํ๊ธฐ ์ด๋ ต๋ค. ์ด๋ฐ ๊ฒฝ์ฐ ์ด๋ค์๋ฏธ๋ฅผ ๊ฐ์ง๋์ง ๋ช ๋ฃํ๊ฒ ์ ์ด์ฃผ๋๋ฐ ํ์ฉํ๋ฉด ์ ์ฉํ๋ค.
๊ฒฐ๊ณผ๋ฅผ ๊ฒฝ๊ณ ํ๋ ์ฃผ์
// ์ฌ์ ์๊ฐ์ด ์ถฉ๋ถํ์ง ์๋ค๋ฉด ์คํํ์ง ๋ง์ญ์์ค
public void _testWithReallyBigFile() {
writeLinesToFile(1000000000);
response.setBody(testFile);
response.readyToSend(this);
String responseString = output.toString();
assertSubString("Content-Length: 1000000000", responseString);
assertTrue(bytesSent > 1000000000);
}
์์ฆ์ @Ignore
์์ฑ์ ์ด์ฉํ์ฌ ํ
์คํธ ์ผ์ด์ค๋ฅผ ๊บผ๋ฒ๋ฆฐ๋ค. @Ignore("์คํ์ด ๋๋ฌด ์ค๋ ๊ฑธ๋ฆฐ๋ค")
public static SimpleDateFormat makeStandardHttpDateFormat() {
// SimpleDateFormat์ ์ค๋ ๋์ ์์ ํ์ง ๋ชปํ๋ค
// ๋ฐ๋ผ์ ๊ฐ ์ธ์คํด์ค๋ฅผ ๋
๋ฆฝ์ ์ผ๋ก ์์ฑํด์ผ ํ๋ค.
SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df;
}
TODO ์ฃผ์
// TODO-MdM ํ์ฌ ํ์ํ์ง ์๋ค.
// ์ฒดํฌ์์ ๋ชจ๋ธ์ ๋์
ํ๋ฉด ํจ์๊ฐ ํ์ ์๋ค.
protected VersionInfo makeVersion() throws Exception {
return null;
}
ํ์ํ๋ค ์ฌ๊ธฐ์ง๋ง ๋น์ฅ ๊ตฌํํ๊ธฐ ์ด๋ ค์ด ์ ๋ฌด๋ฅผ ๊ธฐ์ ํ๋ค. ํ์ง๋ง ํ๊ณ๊ฐ ๋์ด์๋ ์๋๋ค.
์ค์์ฑ์ ๊ฐ์กฐํ๋ ์ฃผ์
String listItemcontent = match.group(3).trim();
// ์ฌ๊ธฐ์ trim์ ๊ต์ฅํ ์ค์ํ๋ค. trim ํจ์๋ ๋ฌธ์์ด์์ ์์ ๊ณต๋ฐฑ์ ์ ๊ฑฐํ๋ค
// ๋ฌธ์์ด์ ์์ ๊ณต๋ฐฑ์ด ์์ผ๋ฉด ๋ค๋ฅธ ๋ฌธ์์ด๋ก ์ธ์๋๊ธฐ ๋๋ฌธ์ด๋ค.
new ListItemWidget(this, listItemcontent, this.level + 1);
return buildList(text.substring(match.end()));
๋์๋กญ์ง ์๊ฒ ์ฌ๊ฒจ์ง ์ ์์ผ๋, ์๋นํ ์ค์ํ ๊ฒฝ์ฐ ์ฃผ์์ ๋จ๊ฒจ๋๋ฉด ์ข๋ค.
๋์ ์ฃผ์
๋๋ค์ ์ฃผ์์ ์ด ๋ฒ์ฃผ์ ์ํ๋ค.
์ฃผ์ ๊ฑฐ๋ฆฌ๋ ์ฃผ์
public void loadProperties() {
try {
String propertiesPath = propertiesLocation + "/" + PROPERTIES_FILE;
FileInputStream propertiesStream = new FileInputStream(propertiesPath);
loadedProperties.load(propertiesStream);
} catch (IOException e) {
// ์์ฑ ํ์ผ์ด ์๋ค๋ฉด ๊ธฐ๋ณธ๊ฐ์ ๋ชจ๋ ๋ฉ๋ชจ๋ฆฌ๋ก ์ฝ์ด ๋ค์๋ค๋ ์๋ฏธ๋ค.
}
}
์ง๋์น๊ฒ ์ถ์์ ์ด๋ค. ๋๊ฐ ๊ธฐ๋ณธ ๊ฐ์ ๋ฉ๋ชจ๋ฆฌ๋ก ์ฝ์ด ๋ค์๋๊ฐ? ์๊ธฐ๋ ์ธ์ ์ธ๊ฐ? ๋๊ฐ ์์ธ๋ฅผ ๋์ง๋๊ฐ? ๊ฒฐ๊ตญ ์ฝ๋๋ฅผ ์ฝ๋ ์ ๋ฐ์ ์๋ค. ์์ฐ์ฑ์ ์ ํ ๋์์ด ๋์ง ์๋๋ค.
๊ฐ์ ์ด์ผ๊ธฐ๋ฅผ ์ค๋ณตํ๋ ์ฃผ์
// this.closed๊ฐ true์ผ ๋ ๋ฐํ๋๋ ์ ํธ๋ฆฌํฐ ๋ฉ์๋๋ค.
// ํ์์์์ ๋๋ฌํ๋ฉด ์์ธ๋ฅผ ๋์ง๋ค.
public synchronized void waitForClose(final long timeoutMillis)
throws Exception
{
if (!closed) {
wait(timeoutMillis);
if (!closed)
throw new Exception("MockResponseSender could not be closed");
}
}
์ฝ๋๋ฅผ ์ฝ์ด๋ ์๋ ์๊ธฐ๋ฅผ ๊ตณ์ด ์ฃผ์์ ๋ฌ์๋์๋ค. ์ฝ๊ธฐ ํ๋ ์ฝ๋๋ฅผ ๋์์ฃผ์ง๋ ์๋๋ค.
/**
* ์ด ์ปดํฌ๋ํธ์ ํ๋ก์ธ์ ์ง์ฐ๊ฐ
*/
protected int backgroundProcessorDelay = -1;
/**
* ์ด ์ปดํฌ๋ํธ๋ฅผ ์ง์ํ๊ธฐ ์ํ ์๋ช
์ฃผ๊ธฐ ์ด๋ฒคํธ
*/
protected LifecycleSupport lifecycle = new LifecycleSupport(this);
์ ํ ๋ชฉ์ ์ด ์๋ค. ์ฝ๋๋ง ์ฝ์ผ๋ฉด ๋๋ฉด ์๋ ๊ฒ์ ์ค๋ณตํด์ ์ ์ด๋์๋ค.
์คํดํ ์ฌ์ง๊ฐ ์๋ ์ฃผ์
// this.closed๊ฐ true์ผ ๋ ๋ฐํ๋๋ ์ ํธ๋ฆฌํฐ ๋ฉ์๋๋ค.
// ํ์์์์ ๋๋ฌํ๋ฉด ์์ธ๋ฅผ ๋์ง๋ค.
public synchronized void waitForClose(final long timeoutMillis)
throws Exception
{
if (!closed) {
wait(timeoutMillis);
if (!closed)
throw new Exception("MockResponseSender could not be closed");
}
}
์ฃผ์์ ๋ณด๋ฉด true์ผ ๋ ๋ฐํ๋๋ค
๋ผ๊ณ ์ ํ์๋ค. ์๋ชป ์ฝ์ผ๋ฉด return value๊ฐ ์๋ ๊ฒ์ผ๋ก ๊ธฐ๋ํ๊ณ ์ฝ๋๋ฅผ ์์ฑํ ์ ์๋ค. ํ์ง๋ง this.closed == true
๊ฐ ์ค๊ฐ์ ๋ณ๊ฒฝ๋๋ค๋ฉด ๋ฉ์๋๋ ๋ฐํ๋์ง ์๋๋ค.
์๋ฌด์ ์ผ๋ก ๋ค๋ ์ฃผ์
/
* @param title CD ์ ๋ชฉ
* (Qparam author CD ์ ์
* @param tracks CD ํธ๋ ์ซ์
* (aparam durationlnMinutes CD ๊ธธ์ด(๋จ์: ๋ถ)
*/
public void addCD(String title, String author,int tracks, int durationlnMinutes) {
CD cd = new CD();
cd.title = title;
cd.author = author;
cd.tracks = tracks;
cd.duration = durationlnMinutes;
cdList.add(cd);
}
ํ๋ฑ์ ์ธ๋ชจ ์๋ค.
์ด๋ ฅ์ ๊ธฐ๋กํ๋ ์ฃผ์
* ๋ณ๊ฒฝ ์ด๋ ฅ (U-Oct-2001๋ถํฐ)
* ----------------------
* 11-Oct-2001 : ํด๋์ค๋ฅผ ๋ค์ ์ ๋ฆฌํ๊ณ ์๋ก์ด ํจํค์ง์ธ com.jrefinery.date๋ก ์ฎ๊ฒผ๋ค (DG);
* 05-Nov-2001 : getDesc ript ion () ๋ฉ์๋๋ฅผ ์ถ๊ฐํ์ผ๋ฉฐ
* NotableDate class๋ฅผ ์ ๊ฑฐํ๋ค (DG);
์์ ์๋ ์ด๊ฒ ๋ง์๋ค. ์์ค ์ฝ๋ ๊ด๋ฆฌ ์์คํ ์ด ์๊ธด ์ดํ์๋ ์ ํ ํ์์์ด์ง ์น๊ตฌ๋ค.
์์ผ๋ ๋ง๋ํ ์ฃผ์
try {
doSending();
} catch (SocketException e) {
// ์ ์ ๋๊ตฐ๊ฐ ์์ฒญ์ ๋ฉ์ท๋ค
} catch (Exception e) {
try {
response.add(ErrorResponder.makeExceptionString(e));
response.closeAll();
} catch (Exception e1) {
// ์ด๊ฒ ๋ญ์ผ
}
}
}
๋ถํ์ด๋ฅผ ํ๊ณ ์๋ค.
private void startSending() {
try {
doSending();
} catch (SocketException e) {
// ์ ์ ๋๊ตฐ๊ฐ ์์ฒญ์ ๋ฉ์ท๋ค
} catch (Exception e) {
addExceptionAndCloseResponse(e);
}
}
private void addExceptionAndCloseResponse(Exception e) {
try {
response.add(ErrorResponder.makeExceptionString(e));
response.closeAll();
} catch (Exception e) {
}
}
๋ถํ์ด ํ ๋์ ํจ์ ๊ฐ์ ํด๋ผ.
ํจ์๋ ๋ณ์๋ก ํํํ ์ ์๋ค๋ฉด ์ฃผ์์ ๋ฌ์ง ๋ง๋ผ
//์ ์ญ ๋ชฉ๋ก <smodule>์ ์ํ๋ ๋ชจ๋์ด ์ฐ๋ฆฌ๊ฐ ์ํ ํ์์์คํ
์ ์์กดํ๋๊ฐ
if (smodule.getDependSubsystems().contains(subSysMod.getSubSystem())) {
}
ArrayList moduleDependees = smodule.getDependSubsystems();
String ourSubSystem = subSysMod.getSubSystem();
if (moduleDependees.contains(ourSubSystem)){
}
์ ๋ ๊ฒ ๊ธธ๊ฒ ๋์ด์์ ์๋ ํํ์ด ์๋๋ค๊ณ ์ฃผ์์ ์ฐ์ง ๋ง๋ผ. ์คํ๋ ค ๋ณ์์ ๋ด์์ ์๋๋ฅผ ํํํ๋ ๊ฒ์ด ์ข๋ค.
์์น๋ฅผ ํํํ๋ ์ฃผ์
// Actions /////////////////////////////////////////////
ํ์ํ ๋ ๋๋ฌผ๊ฒ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข๋ค. ์ผ๋ฐ์ ์ผ๋ก ์์ ๊ฐ์ ์ฃผ์์ ๊ฐ๋ ์ฑ๋ง ๋ฎ์ถ๋ค.
๋ซ๋ ๊ดํธ์ ๋ค๋ ์ฃผ์
public class wc {
public static void main(String[] args) {
BufferedReader in = new BufferedReader(newInputStreamReader(System.in));
String line;
int lineCount = 0;
int charCount = 0;
int wordCount = 0;
try {
while ((line = in.readLineO) != null) {
lineCount++;
charCount += line.length();
String words[] = line.split("\\W");
wordCount += words.length;
} //while
System.out.printIn("wordCount = " + wordCount);
System.out.printIn("lineCount = " + lineCount);
System.out.printIn("cha rCount = " + charCount);
} //try
์ค์ฒฉ์ด ์ฌํ๊ณ ์ฅํฉํ ํจ์(flutter์์ ๋ด)์ ๊ฒฝ์ฐ์๋ ์ ์ฉํ๋ ์๊ณ ์บก์ํ๋ ํจ์์๋ ์ก์์ผ ๋ฟ์ด๋ค.
๊ณต๊ณ ๋ฅผ ๋๋ฆฌ๊ฑฐ๋ ์ ์๋ฅผ ํ์ํ๋ ์ฃผ์
/* ์์์ด ์ถ๊ฐํจ */
์์ค ์ฝ๋ ๊ด๋ฆฌ ์์คํ ์ด ๋ชจ๋ ์ฒ๋ฆฌํด์ค๋ค.
์ฃผ์์ผ๋ก ์ฒ๋ฆฌํ ์ฝ๋
InputStreamResponse response = new InputStreamResponse();
response.setBody(formatter.getResultStream(), formatter.getByteCount());
// InputStream resultsStream = formatter.getResultStream();
// StreamReader reader = new StreamReader(resultsStream);
// response. setContent( reader. read(form atter.getByteCount( ) ) ) ;
์ด๊ฒ ์ ์ผ ๋ฐ์ด์ค๋ฌ์ด ๊ดํ์ด๋ค. ์ด๋ฐ ์ฝ๋๋ ์์ฑํ์ง ๋ง๋ผ! ๋ค๋ฅธ ์ฌ๋๋ค์ด ์ด๋ฅผ ์ง์ฐ๊ธฐ๋ฅผ ์ฃผ์ ํ๋ค. ์ด์ ๊ฐ ์๊ฒ ์ง ํ๋ฉด์ ์์ง์ฐ๋ ๋ ์์ด๋ค. ์ด๋ฌ๋ค๋ณด๋ฉด ์์ฒญ๋๊ฒ ์์ด๊ฒ ๋๋ค. ์์ค ์ฝ๋ ๊ด๋ฆฌ ์์คํ ์ ๋ฏฟ๊ณ ์ง์๋ฒ๋ฆฌ์.
HTML ์ฃผ์
/ **
* ์ ํฉ์ฑ ํ
์คํธ๋ฅผ ์ํํ๊ธฐ ์ํ ๊ณผ์
* ์ด ๊ณผ์
์ ์ ํฉ์ฑ ํ
์คํธ๋ฅผ ์ํํด ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๋ค.
* <p/>
* <pre>
* ์ฉ๋ฒ:
* <taskdef name="execute-fitnesse-tests"
* classname="fitnesse.ant.ExecuteFitnesseTestsTask"
์์ ํ์ค๋ค. ์ผ๋จ ์ฝ๊ธฐ๊ฐ ์ด๋ ต๋ค.
์ ์ญ ์ ๋ณด
/*
* ์ ํฉ์ฑ ํ
์คํธ๊ฐ ๋์งํ๋ ํฌํธ: ๊ธฐ๋ณธ๊ฐ์ <b>8082</b>.
* (aparam fitnessePort)
*/
public void setFitnessePort(int fitnessePort)
{
this.fitnessePort = fitnessePort;
}
์ฃผ์์ ๋ฌ์์ผ ํ๋ค๋ฉด ๊ทผ์ฒ ์ฝ๋์๋ง ๊ธฐ์ ํด๋ผ. ์์ ๊ฒฝ์ฐ, ํด๋น ํจ์ ์์ฒด๋ ๊ธฐ๋ณธ ํฌํธ ๊ฐ์ ์ ํ ํต์ ํ์ง ๋ชปํ๋ค. ์ฆ, ๋ฐ๋ก ์๋ ํจ์์ ์ ์ฉ๋๋ ๊ฒ์ด ์๋๊ณ , ์์คํ ์ด๋๊ฐ์ ์๋ ๋ค๋ฅธ ํจ์๋ฅผ ์ค๋ช ํ๋ค๋ ๋ง์ด๋ค.
๋๋ฌด ๋ง์ ์ ๋ณด
/*
RFC 2045 - Multipurpose Internet Mail Extensions (MIME)
1๋ถ: ์ธํฐ๋ท ๋ฉ์์ง ๋ณธ์ฒด ํ์
6.8์ . Base64 ๋ด์ฉ ์ ์ก ์ธ์ฝ๋ฉ(Content-Transfer-Encoding)
์ธ์ฝ๋ฉ ๊ณผ์ ์์
๋ ฅ ๋นํธ ์ค 24๋นํธ ๊ทธ๋ฃน์ ์ธ์ฝ๋ฉ๋ 4๊ธ์๋ก ๊ตฌ์ฑ๋
์ถ๋ ฅ ๋ฌธ์์ด๋ก ํํํ๋ค. ์ผ์ชฝ์์ ์ค๋ฅธ์ชฝ์ผ๋ก ์งํํด๊ฐ๋ฉฐ, 3๊ฐ๋ฅผ ๋ฌถ์ด 8๋นํธ ์
๋ ฅ
๊ทธ๋ฃน์ ํ์ฑํ๋ค. ์ด๋ ๊ฒ ๋ง๋ค์ด์ง 24๋นํธ๋ 4๊ฐ๋ฅผ ๋ฌถ์ด 6๋นํธ ๊ทธ๋ฃน์ผ๋ก ์ทจ๊ธํ๋ฉฐ,
๊ฐ๊ฐ์ base64 ์ํ๋ฒณ์์ ๋จ์ผ ์๋ฆฟ์๋ก ํด์๋๋ค.
base64 ์ธ์ฝ๋ฉ์ผ๋ก ๋นํธ ์คํธ๋ฆผ์ ์ธ์ฝ๋ฉํ ๋, ๋นํธ ์คํธ๋ฆผ์
MSB(Most Significant Bit) ์ฐ์ ์ผ๋ก ์ ๋ ฌ๋์ด ์๋ค๊ณ ๊ฐ์ ํ๋ค. ๋ฐ๋ผ์, ์คํธ๋ฆผ์์
์ฒซ ๋ฒ์งธ ๋นํธ๋ ์ฒซ 8๋นํธ ๋ฐ์ดํธ์์ ์ต์์ ๋นํธ๊ฐ ๋๋ฉฐ, ์ฌ๋๋ฒ์งธ ๋นํธ๋ ์ฒซ 8๋นํธ
๋ฐ์ดํธ์์ ์ตํ์ ๋นํธ๊ฐ ๋๋ค.
*/
๊ฑฐ์ ๋ฐฑ๊ณผ์ฌ์ ์์ค์ด๋ค. ์ฝ๋ ์ฌ๋์๊ฒ๋ ์ฌ์ค ์ ํ ํ์์๋ ์ ๋ณด์ด๋ค.
๋ชจํธํ ๊ด๊ณ
/*
* ๋ชจ๋ ํฝ์
์ ๋ด์ ๋งํผ ์ถฉ๋ถํ ๋ฐฐ์ด๋ก ์์ํ๋ค(์ฌ๊ธฐ์ ํํฐ ๋ฐ์ดํธ๋ฅผ ๋ํ๋ค) .
* ๊ทธ๋ฆฌ๊ณ ํค๋ ์ ๋ณด๋ฅผ ์ํด 200๋ฐ์ดํธ๋ฅผ ๋ํ๋ค.
*/
this.pngBytes = new byte[((this.width + 1) * this.height * 3) + 200];
์ฃผ์๊ณผ ์ฃผ์์ด ์ค๋ช ํ๋ ์ฝ๋๋ ๊ด๊ณ๊ฐ ๋ช ํํด์ผ ํ๋ค. ์ ์ฝ๋์์ ํํฐ ๋ฐ์ดํธ๋ ๋ฌด์์ธ๊ฐ? ์ ํ ์ ์ ์๋ค. ์ฃผ์ ์์ฒด๊ฐ ๋ค์ ์ค๋ช ์ ์๊ตฌํ๋ ์ํ๊น๊ธฐ ๊ทธ์ง์๋ค.
ํจ์ ํค๋
์งง์ ํจ์๋ ๊ธด ์ค๋ช ์ด ํ์์๋ค. ํ ๊ฐ์ง๋ง ์ ์ํํ๋ ์งง๊ณ ์ด๋ฆ ์ ๋ถ์ธ ํจ์๋ ์ฃผ์์ผ๋ก ํค๋๋ฅผ ์ถ๊ฐํ ํจ์๋ณด๋ค ํจ์ฌ ์ข๋ค.
๋ง๋ฌด๋ฆฌ
์ฃผ์์ ์๋๋ฐฉ์ ์ ์ฅ์์ ๋ณด์์ ๋, ์ข์์ง ๋์ ์ง๋ฅผ ํ๋จํด์ ์ ๋ ๊ฒ์ด ์ค์ํ๋ค.