반응형

<%@ page language="java" import="java.util.*, java.sql.*, java.io.*" session="true" contentType="text/html;charset=euc-kr" pageEncoding="euc-kr" %>
<HTML>
<HEAD>
<title>엑셀 </title>
<meta content="text/html"; charset="euc-kr">
</head>

<body>
<%
        request.setCharacterEncoding("euc-kr");         // 한글 인코딩 설정    

try
{
        String fullPath = "/TforWindows/Tomcat5/webapps/ROOT/";
        StringBuffer sb = new StringBuffer(); //파일을 서버에 만들기 시작
        String fileName = "aaa.xls";
        
        //확장자는 xls,txt,csv 다 허용함다...
        //단지 xls,csv파일일때는 \t로 데이타를 구분해야하죠
        //그렇지만 내부적으로는 다 txt파일임다..어떤 에디터에서나 다 열리는...
        
        FileOutputStream fos = new FileOutputStream(fullPath + fileName);
        DataOutputStream dos = new DataOutputStream(fos);
        OutputStreamWriter osw = new OutputStreamWriter(dos,"MS949");  // 한글로 내용을 쓰셔야죠..
        
        //파일에 들어갈 내용들을 버퍼에 넣는다.
        sb.append("내용1");
        sb.append("\t"); //cvs파일인가?용이고..데이타의 구분이죠(tab)
        sb.append("내용2");
        sb.append("\r\n"); //파일에 버퍼의 내용을 적는다.
        
        osw.write(sb.toString(), 0, sb.length() );

        sb.delete(0,sb.length()-1); //버퍼를 지운다.
        
        //꼭 닫아주세요 ^^
        osw.close();
        dos.close();
        fos.close();
                
        
        }catch(IOException ioe){
                 out.println(ioe);
                 out.println("머야?");
        }catch(Exception ex){
                 out.println(ex);
                 out.println("머시기?");
        }
%>
</body>
</html>
반응형

'WEB > CGI' 카테고리의 다른 글

PHP MSSQL용 API  (0) 2010.10.21
2000 이후 달라진 SMTP (ASP, CDO)  (0) 2010.10.21
*OutputStream 한글 인코딩 처리  (0) 2010.10.21
JSP 파일 업로드  (0) 2010.10.21
PHP 파일의 확장자 분리하기  (0) 2010.10.21
반응형

-------------------------------------------------------------
질문
-------------------------------------------------------------
다음은 저의 허접 소스의 일부입니다.  
한글이 깨져서 나오는데, 이를 해결할 수 있는 방법이 있나요??  
================================================
try
{

sNewFileName = rd.sSaveDir + rd.vFileName.elementAt(FileNum).toString() + "N";
OutputStream os = new FileOutputStream(sNewFileName);
DataOutputStream out = new DataOutputStream(os);

for(int i=0; i < rd.vDB.size(); i++)
{
out.writeBytes("INSERT INTO =TMT003 VALUES(\"");
out.writeBytes(rd.vDB.elementAt(i).toString());
out.writeBytes("\", \"");
out.writeBytes(rd.vTable.elementAt(i).toString());
out.writeBytes("\");");
out.writeBytes("한글 테스트");
out.writeBytes("\n");
out.writeChars("한글 테스트");
out.writeBytes("\n");
out.writeUTF("한글 테스트");
out.writeBytes("\n");
}
return true;
}



-------------------------------------------------------------
답!!!
-------------------------------------------------------------
맞는 방법인지 틀린 방법인지도 모르겠지만

어쨋든 한글은 되게 하는 방법입니다 --;;

import java.io.*;

public class IOTest {
public static void main(String args[]){
try {  
String sNewFileName = "test.txt";  
OutputStream os = new FileOutputStream(sNewFileName);  
DataOutputStream out = new DataOutputStream(os);  
OutputStreamWriter osw = new OutputStreamWriter( out );
osw.write( "한글 테스트" , 0 , "한글 테스트".length() );  
osw.close();
out.close();
os.close();
} catch ( Exception e ) {
e.printStackTrace();
}
  }
}

반응형

'WEB > CGI' 카테고리의 다른 글

2000 이후 달라진 SMTP (ASP, CDO)  (0) 2010.10.21
csv 파일 서버 저장 JSP  (0) 2010.10.21
JSP 파일 업로드  (0) 2010.10.21
PHP 파일의 확장자 분리하기  (0) 2010.10.21
E-mail programming 관련  (0) 2010.10.20
반응형

Java 2 SDK, Standard Edition, v. 1.4.2 Installation Notes

기본 설치
Download j2sdk-1_4_2_03-linux-i586.bin (다운받은다음 644나 755권한을)
다운로드 받은 j2sdk-1_4_2_03-linux-i586.bin 파일을 설치를 원하는 디렉토리에 복사한다. (일반적으로 /usr/local/)
권한을 다음 처럼되어있는지 확인 혹 설정한다.
chmod 755 j2sdk-1_4_2_03-linux-i586.bin

파일이 있는 곳에서 다음과 같이 명령한다.
./j2sdk-1_4_2_03-linux-i586.bin

링크를 걸어준다.
ln -s /usr/local/j2sdk1.4.2_03 /usr/local/j2sdk

환경 설정
어느곳에서나 java 명령을 쳐도 이를 인식하고 또 기본 jar 파일 들을 클래스 패스에 등록하기 위해 다음 파일을 수정(혹 만듬)한다.
vi /etc/profile.d/jdk.sh

다음과 같은 내용을 적는다.
#export JAVA_HOME="/usr/local/j2se"
export JAVA_HOME="/usr/local/j2sdk"
export PATH="$PATH:$JAVA_HOME/bin"
export CLASSPATH=".:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/jre/lib/rt.jar"
export CLASSPATH="$CLASSPATH:$JAVA_HOME/jre/lib/ext"

만약 톰캣이 깔려있다면 다음 줄도 추가한다.(아마도 이 라인은 톰캣을 깐 후에 하는 작업이 될듯)
export CLASSPATH="$CLASSPATH:$CATALINA_HOME/lib/servlet.jar"

vi를 저장하고 빠져나온다.
저장한 내용을 반영시키기 위해 다음과 같이 타입한다.
source /etc/profile

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

JDK 설치

1. 설치파일
Java(TM) 2 Platform Standard Edition Development Kit
-> Download : http://java.sun.com/
-> jdk-1_5_0_06-linux-i586-rpm.bin (자동실행파일)

2. 설치

[root@voyager jdk]# chmod 755 jdk-1_5_0_06-linux-i586-rpm.bin
[root@voyager jdk]# ./jdk-1_5_0_06-linux-i586-rpm.bin
Sun Microsystems, Inc. Binary Code License Agreement

for the JAVA 2 PLATFORM STANDARD EDITION DEVELOPMENT KIT 5.0

중략...

For inquiries please contact: Sun Microsystems, Inc., 4150 Network
Circle, Santa Clara, California 95054, U.S.A. (LFI#141623/Form
ID#011801)

Do you agree to the above license terms? [yes or no]
y
Unpacking...
Checksumming...
0
0
Extracting...
UnZipSFX 5.42 of 14 January 2001, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-1_5_0_06-linux-i586.rpm
준비 중... ########################################### [100%]
1:jdk ########################################### [100%]

Done.
[root@voyager jdk]# rpm -qi jdk
Name : jdk Relocations: /usr/java
Version : 1.5.0_06 Vendor: Sun Microsystems, Inc.
Release : fcs Build Date: 2005년 11월 11일 (금) 오전 07시 20분 19초
Install Date: 2006년 04월 26일 (수) 오전 11시 41분 59초 Build Host: tiger-linux
Group : Development/Tools Source RPM: jdk-1.5.0_06-fcs.src.rpm
Size : 84094742 License: Sun Microsystems Binary Code License (BCL)
Signature : (none)
Packager : Java Software
URL : http://java.sun.com/
Summary : Java(TM) 2 Platform Standard Edition Development Kit
Description :
The Java 2 Platform Standard Edition Development Kit (JDK) includes both the
runtime environment (Java virtual machine, the Java platform classes and
supporting files) and development tools (compilers, debuggers, tool libraries
and other tools).

The JDK is a development environment for building applications, applets and
components that can be deployed with the Java 2 Platform Standard Edition
Runtime Environment.
반응형
반응형

설치한 jdk의 javac와 java를 심볼릭링크로 거세연...
반응형

+ Recent posts