πΒ μ€λ μ½μ λ²μ : 4μ₯ μ£Όμ (75~94p)
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");
}
}
μΆκ° μ 보λ₯Ό μ 곡 λͺ»νλ μλ―Έμλ μ£Όμ// μ μ λͺ©λ‘ <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(new InputStreamReader(System.in));
String line;
int lineCount = 0;
int charCount = 0;
int wordCount = 0;
try {
while ((line = in .readLine()) != null) {
lineCount++;
charCount += line.length();
String words[] = line.split("\\W");
wordCount += words.length;
} //while
System.out.println("wordCount = " + wordCount);
System.out.println("lineCount = " + lineCount);
System.out.println("charCount = " + charCount);
} //try
catch (IOException e) {
System.err.println("Error:" + e.getMessage());
} //catch } //main
}
1960λ
λκΉμ§λ μ£ΌμμΌλ‘ κ΄λ¦¬νμ§λ§ μ΄μ λ μμ€ κ΄λ¦¬ μμ€ν
μ΄ μμΌλ―λ‘ κ³Όκ°ν μ§μλΌ/**
* μ ν©μ± ν
μ€νΈλ₯Ό μννκΈ° μν κ³Όμ
* μ΄ κ³Όμ
μ μ ν©μ± ν
μ€νΈλ₯Ό μνν΄ κ²°κ³Όλ₯Ό μΆλ ₯νλ€.
* <p/>
* <pre>
* μ©λ²:
* <taskdef name="execute-fitnesse-tests"
* classname="fitnesse.ant.ExecuteFitnesseTestsTask"
* classpathref="classpath" />
* λλ
* <taskdef classpathref="classpath"
* resource="tasks.properties" />
* <p/>
* <execute-fitnesse-tests
* suitepage="FitNesse.SuiteAcceptanceTests"
* fitnesseport="8082"
* resultsdir="${results.dir}"
* resultshtmlpage="fit-results.html"
* classpathref="classpath" />
* </pre> */
/*
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λΉνΈ λ°μ΄νΈμμ μ΅νμ λΉνΈκ° λλ€.
*/
/*
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μ μ λνλμ§ μ μ κ°μλ€/**
* μ΄ ν΄λμ€λ μ¬μ©μκ° μ§μ ν μ΅λ κ°κΉμ§ μμλ₯Ό μμ±νλ€. μ¬μ©λ μκ³ λ¦¬μ¦μ
* μλΌμ€ν ν
λ€μ€μ 체λ€.
* <p>
* μλΌμ€ν ν
λ€μ€: κΈ°μμ 276λ
μ 리λΉμ ν€λ λ€μμ μΆμ, κΈ°μμ 194λ
μ μ¬λ§
* μ§κ΅¬ λλ λ₯Ό μ΅μ΄λ‘ κ³μ°ν μ¬λμ΄μ λ¬λ ₯μ μ€λ
μ λμ
ν μ¬λ.
* μλ μ°λ리μ λμκ΄μ₯μ μμ.
* <p>
* μκ³ λ¦¬μ¦μ μλΉν λ¨μνλ€. 2μμ μμνλ μ μ λ°°μ΄μ λμμΌλ‘
* 2μ λ°°μλ₯Ό λͺ¨λ μ κ±°νλ€. λ€μμΌλ‘ λ¨μ μ μλ₯Ό μ°Ύμ μ΄ μ μμ λ°°μλ₯Ό λͺ¨λ μ§μ΄λ€.
* μ΅λ κ°μ μ κ³±κ·Όμ΄ λ λκΉμ§ μ΄λ₯Ό λ°λ³΅νλ€. *
* @author Alphonse
* @version 13 Feb 2002 atp */
import java.util.*;
public class GeneratePrimes {
/**
* @param maxValueλ μμλ₯Ό μ°ΎμλΌ μ΅λ κ°
*/
public static int[] generatePrimes(int maxValue) {
if (maxValue >= 2) // μ μΌνκ² μ ν¨ν κ²½μ°
{
// μ μΈ
int s = maxValue + 1; // λ°°μ΄ ν¬κΈ°
boolean[] f = new boolean[s];
int i;
// λ°°μ΄μ μ°ΈμΌλ‘ μ΄κΈ°ν
for (i = 0; i < s; i++)
f[i] = true;
// μμκ° μλ μλ €μ§ μ«μλ₯Ό μ κ±°
f[0] = f[1] = false;
// 체
int j;
for (i = 2; i < Math.sqrt(s) + 1; i++) {
if (f[i]) // iκ° λ¨μ μλ μ«μλΌλ©΄ μ΄ μ«μμ λ°°μλ₯Ό ꡬνλ€. {
for (j = 2 * i; j < s; j += i)
f[j] = false; // λ°°μλ μμκ° μλλ€.
}
}
// μμ κ°μλ?
int count = 0;
for (i = 0; i < s; i++) {
if (f[i])
count++; // μΉ΄μ΄νΈ μ¦κ°
}
int[] primes = new int[count];
// μμλ₯Ό κ²°κ³Ό λ°°μ΄λ‘ μ΄λνλ€.
for (i = 0, j = 0; i < s; i++) {
if (f[i]) // μμμΌ κ²½μ°μ
primes[j++] = i;
}
return primes; // μμλ₯Ό λ°ννλ€. }
else // maxValue < 2
return new int[0]; // μ
λ ₯μ΄ μλͺ»λλ©΄ λΉμ΄ μλ λ°°μ΄μ λ°ννλ€.
}
}
μλμ½λλ‘ λ³κ²½
/**
* μ΄ ν΄λμ€λ μ¬μ©μκ° μ§μ ν μ΅λ κ°κΉμ§ μμλ₯Ό ꡬνλ€. * μκ³ λ¦¬μ¦μ μλΌμ€ν ν
λ€μ€μ 체λ€.
* 2μμ μμνλ μ μ λ°°μ΄μ λμμΌλ‘ μμ
νλ€.
* μ²μμΌλ‘ λ¨μ μλ μ μλ₯Ό μ°Ύμ λ°°μλ₯Ό λͺ¨λ μ κ±°νλ€. * λ°°μ΄μ λ μ΄μ λ°°μκ° μμ λκΉμ§ λ°λ³΅νλ€.
*/
public class PrimeGenerator {
private static boolean[] crossedOut;
private static int[] result;
public static int[] generatePrimes(int maxValue) {
if (maxValue < 2) return new int[0];
else {
uncrossIntegersUpTo(maxValue);
crossOutMultiples();
putUncrossedIntegersIntoResult();
return result;
}
}
private static void uncrossIntegersUpTo(int maxValue) {
crossedOut = new boolean[maxValue + 1];
for (int i = 2; i < crossedOut.length; i++)
crossedOut[i] = false;
}
private static void crossOutMultiples() {
int limit = determineIterationLimit();
for (int i = 2; i <= limit; i++)
if (notCrossed(i)) crossOutMultiplesOf(i);
}
private static int determineIterationLimit() {
// λ°°μ΄μ μλ λͺ¨λ λ°°μλ λ°°μ΄ ν¬κΈ°μ μ κ³±κ·Όλ³΄λ€ μμ μμμ μΈμλ€.
// λ°λΌμ μ΄ μ κ³±κ·Όλ³΄λ€ λ ν° μ«μμ λ°°μλ μ κ±°ν νμκ° μλ€.
double iterationLimit = Math.sqrt(crossedOut.length);
return (int) iterationLimit;
}
private static void crossOutMultiplesOf(int i) {
for (int multiple = 2 * i; multiple < crossedOut.length; multiple += i; crossedOut[multiple] = true;
}
private static boolean notCrossed(int i) {
return crossedOut[i] == false;
}
private static void putUncrossedIntegersIntoResult() {
result = new int[numberOfUncrossedIntegers()];
for (int j = 0, i = 2; i < crossedOut.length; i++)
if (notCrossed(i)) result[j++] = i;
}
private static int numberOfUncrossedIntegers() {
int count = 0;
for (int i = 2; i < crossedOut.length; i++)
if (notCrossed(i)) count++;
return count;
}
}
첫 λ²μ§Έ μ£Όμ: generatePrimse λΌλ ν¨μ μ΄λ¦μΌλ‘ μ€λͺ μ΄ λκΈ΄ νμ§λ§ μκ³ λ¦¬μ¦μ μ¬μ΄ μ΄ν΄λ₯Ό μν΄ λ¨κ²¨λ
λ λ²μ§Έ μ£Όμ: 루ν νκ³κ°μΌλ‘ μ κ³±κ·Όμ μ¬μ©ν μ΄μ λ₯Ό μ€λͺ (μ½λλ‘ μ€λͺ νκ³ μμ)