import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.IOException;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Iterator;

import java.util.LinkedHashMap;

import java.util.List;

import java.util.Map;



public class TestCSV {


public static void main(String[] args) throws IOException {

List<Map> list = new ArrayList<Map>();

Map<String, String> mapTitle = new LinkedHashMap<String, String>();

mapTitle.put("num", "순번");

mapTitle.put("num1", "제목");

mapTitle.put("num2", "내용");

mapTitle.put("num3", "기타1");

mapTitle.put("num4", "기타2");

mapTitle.put("num5", "기타3");

mapTitle.put("num6", "기타4");

mapTitle.put("num7", "기타5");

mapTitle.put("num8", "기타6");

mapTitle.put("num9", "기타7");

list.add(mapTitle);

for(int i=0; i<10000; i++){

Map mapContents = new LinkedHashMap();

mapContents.put("key1", "value1 : " + i);

mapContents.put("key2", "value2 : " + i);

mapContents.put("key3", "value3 : " + i);

mapContents.put("key4", "value4 : " + i);

mapContents.put("key5", "value5 : " + i);

mapContents.put("key6", "value6 : " + i);

mapContents.put("key7", "value7 : " + i);

mapContents.put("key8", "value8 : " + i);

mapContents.put("key9", "value9 : " + i);

mapContents.put("key10", "value10 : " + i);

list.add(mapContents);

}

BufferedWriter out = new BufferedWriter(new FileWriter("C:\\Users\\e1x00.HIMARTINFRA\\Desktop\\out.csv"));

String str = "";

Iterator<String> iterator = list.get(0).keySet().iterator();

   while (iterator.hasNext()) {

       String key = (String) iterator.next();

       str += list.get(0).get(key) + ",";

   }

   

   str = str.substring(0, str.length()-1);

   out.write(str);

   out.newLine();

for(int i=1; i<list.size(); i++){

str = "";

Iterator<String> iter = list.get(i).keySet().iterator();

   while (iter.hasNext()) {

       String key = (String) iter.next();

       str += list.get(i).get(key) + ",";

   }

   str = str.substring(0, str.length()-1);

   out.write(str);

   out.newLine();

}


out.close();

}

}







public class TestStringFomatter {

public static void main(String[] args) {


// % : 명령 시작을 의미

// 0 : 채워질 문자

// 2 : 총 자리수

// d : 십진수로 된 정수

// %02d : 십진수로 된 2자리의 정수 형식으로 나타냄. 단 자릿수가 부족할 경우 0으로 해당부분을 채움

        System.out.println(String.format("%04d", 8));

        System.out.println(String.format("%04d", 11));

}

}





'Java > Default' 카테고리의 다른 글

mkdir() 과 mkdirs()  (0) 2014.02.27
상속  (0) 2012.03.08
vector - 배열의 사이즈, 용량 예제  (0) 2011.12.20
자바 주석  (0) 2011.12.13


메타데이터 시작으로 이동하기

증상

When sending a test email via an SSL connection (configured as a JNDI resource), mail won't be sent and the following error message is displayed:

com.atlassian.mail.MailException: com.sun.mail.smtp.SMTPSendFailedException:
530 5.7.0 Must issue a STARTTLS command first.

원인

In the JNDI SMTP resource configuration, mail.smtp.starttls.enable isn't turned on.

해결방법

  1. Double check if "JNDI Location" is specified in SMTP Server Setup
  2. Edit <JIRA_Installation_Home>/conf/server.xml (Standalone) or <Catalina_Home>/conf/server.xml (Ear/War)
  3. In the SmtpServer resource section, set mail.smtp.starttls.enable as "true" and configure mail.smtp.socketFactory.class property. A resource configuration sample is shown as below:
    <Resource name="mail/SmtpServer"
    auth="Container"
    type="javax.mail.Session"
    mail.smtp.host="mail.mycompany.com"
    mail.smtp.port="587"
    mail.smtp.auth="true"
    mail.smtp.user="jira@mycompany.com"
    password="mypassword"
    mail.smtp.starttls.enable="true"
    mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
    />








 

mkdirs() - 디렉토리가 여러단개일 경우 부모디렉토리까지만 만들어 준다.

 

mkdir() - 부모디렉토리 밑에 하위 디렉토리가 있는 경우 만들어 주지 않는다.

 


예) 만약 C:\test 라는 폴더가 있을경우

C:\test\aaa 라는 폴더를 만들경우 mkdir(), mkdirs() 모두 사용가능

C:\test\aaa\bbb\ccc 라는 폴더를 만들경우(bbb란 폴더를 생성후 ccc 란 폴더를 만들어야 하는경우) mkdirs()을 사용해야 한다.


mkdir()은 단일 디렉토리의 경우 사용한다.

 

API

 boolean

mkdir()
          Creates the directory named by this abstract pathname.

 

 boolean

mkdirs()
          Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.

 

[출처] mkdir() 과 mkdirs()|작성자 담담




'Java > Default' 카테고리의 다른 글

특정 자리수 만큼 0으로 공백 채우기(String.format())  (0) 2015.05.22
상속  (0) 2012.03.08
vector - 배열의 사이즈, 용량 예제  (0) 2011.12.20
자바 주석  (0) 2011.12.13


request.getSession(true); 
= Request에 대한 새로운 session을 create


request.gerSession(false); 
= 현재 session이 존재하면 기존 session리턴
= 존재하지 않으면 null리턴


request.getSession() ;
= 현재 session이 존재하면 기존session 리턴
= 존재하지 않으면 새로생성한 session리턴





'Java' 카테고리의 다른 글

PrintWriter 한글깨짐  (0) 2014.02.05
Calendar 함수의 날짜 비교  (0) 2013.10.07


// writer 할때 한글이 깨지는 경우

response.setCharacterEncoding("UTF-8");

response.setContentType("text/html; charset=UTF-8");


 

예제)

public void getName(String strCode, HttpServletResponse response) throws IOException {


response.setCharacterEncoding("UTF-8");

response.setContentType("text/html; charset=UTF-8");

PrintWriter writer = response.getWriter();

writer.println("<script type='text/javascript'>");

    writer.println("location.href = '/main/list.do';");

writer.println("</script>");

writer.flush();

writer.close();

}







'Java' 카테고리의 다른 글

request.getSession  (0) 2014.02.16
Calendar 함수의 날짜 비교  (0) 2013.10.07

 

 

Calendar 함수의 날짜 비교 메서드 before, after

 


import java.util.Calendar;


public class TestCode {

public static void main(String[] args) {
    Calendar cal = Calendar.getInstance();
    Calendar cal2 = Calendar.getInstance();
    cal.set(2013, 9, 15);
    cal2.set(2013, 9, 14);
  
    if(cal.after(cal2)){
        System.out.println("cal이 cal2 보다 이후");
    }else{
        System.out.println("cal2이 cal1 보다 이후");
    }
}

}

 

 

 

-----------------------------------------------------------------------

 

결과 : cal이 cal2 보다 이후


 

 

 

'Java' 카테고리의 다른 글

request.getSession  (0) 2014.02.16
PrintWriter 한글깨짐  (0) 2014.02.05


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class DeleteTest {

// select 만 ResultSet이 필요, 

private Connection con;
private Statement stmt;
public DeleteTest(String id){
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "joker7379");
String sql = "delete from new_table where id='" + id + "'" ; // 변수로 처리
stmt = con.createStatement();
int i = stmt.executeUpdate(sql); // 처리된 레코드의 갯수를 리턴
System.out.println("처리된 레코드의 갯수 : " + i);
stmt.close();
con.close();
} catch (SQLException e) {
System.out.println("일반예외 : " + e);
} catch (Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {

new DeleteTest("aaa");
}
}




상속

- 자바는 단일 상속(하나의 클래스로부터만 상속 가능) 만 가능
- public, protected 접근 한정자만 상속
- 부모클래스가 가진 public, protected 메서드를 모두 가진다
- 부모클래스의 private 맴버에는 접근 불가
- 상속받지 않은 클래스에서는 protected 맴버에 접근 불가 


 // 상속 : 부모 타입의 기능을 자식 타입에서 재 사용

// public > protected > default > private
// public :  공용
// protected : 다른 패키지에서도 상속 가능
// 생략(default) : 같은 패키지에서 상속 가능
// private : 상속 불가

class Parent{
// private void hi(){ // 컴파일 에러
protected void hi(){ // 자식클래스에서만 사용가능하도록.. 자식클래스에서만 상속하도록
System.out.println("안녕하세요");
}
}

class Child extends Parent{ // Parent 클래스의 맴버 상속
public void hello(){
System.out.println("반갑습니다");
}
}

public class Inheritance {

public static void main(String[] args) {
Parent p = new Parent();
p.hi();
Child c = new Child();
c.hi();
c.hello();
}
}

--------------------------------------------------------------

안녕하세요
안녕하세요
반갑습니다 

'Java > Default' 카테고리의 다른 글

특정 자리수 만큼 0으로 공백 채우기(String.format())  (0) 2015.05.22
mkdir() 과 mkdirs()  (0) 2014.02.27
vector - 배열의 사이즈, 용량 예제  (0) 2011.12.20
자바 주석  (0) 2011.12.13


package Vector;

import java.util.Vector;

public class VectorTest2 {
 
 public static void main(String[] args) {
  
  Vector v = new Vector(3, 4);
  
  System.out.println(v.size());
  System.out.println(v.capacity());
  
  v.add("망아지");
  v.add("송아지");
  v.add("강아지");
  v.add("병아리");

  System.out.println(v.size());
  System.out.println(v.capacity());
  System.out.println(v);
  
  v.remove("강아지");
  
  System.out.println(v);
  
  System.out.println(v.size());
  System.out.println(v.capacity());
  
  v.setSize(3);
  v.trimToSize();
  
  System.out.println(v.size());
  System.out.println(v.capacity());
  
 }
}


실행결과
0
3
4
7
[망아지, 송아지, 강아지, 병아리]
[망아지, 송아지, 병아리]
3
7
3
3

'Java > Default' 카테고리의 다른 글

특정 자리수 만큼 0으로 공백 채우기(String.format())  (0) 2015.05.22
mkdir() 과 mkdirs()  (0) 2014.02.27
상속  (0) 2012.03.08
자바 주석  (0) 2011.12.13


- 주석

 - 블록 단위의 주석 : /*~*/ (단축키 : shift + ctrl + /)
 - 문장 주석 : //
 - 이클립스에서 주석 처리 : 마우스로 범위 드레그 + ctrl + /

'Java > Default' 카테고리의 다른 글

특정 자리수 만큼 0으로 공백 채우기(String.format())  (0) 2015.05.22
mkdir() 과 mkdirs()  (0) 2014.02.27
상속  (0) 2012.03.08
vector - 배열의 사이즈, 용량 예제  (0) 2011.12.20

+ Recent posts