달력

5

« 2024/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

http://suite.tistory.com/ 2007 5  fs

한글 EUC KR 에서 두글자만 integer 사이까지만 할 경우


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// java 자바로

 //조건: unsiged integer 4바이트 최대값 2000000000로 보고 아래와 같이 글자들간에 차이가 나도록 필자 마음되로 지정

  final int[] chosung = {660,1320,1980,2640,3300,3960,4620,5280,5940,6600,7260,7920,8580,9240,9900,10560,11200,11880,12540};
  final int[] moeum = {30,60,90,120,150,180,210,240,270,300,330,360,390,420,450,480,510,540,570,600,630};
  final int[] badchim = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27};
 
  if (arg_str == null) return "";
 
  String s=arg_str.trim();
 
  value="";
   
  int tmp = 0;
  int n, n1, n2, n3;
  char c;

  // int 최대값 때문에 두글자만 i<2
  for (int i = 0; i<s.length() && i < 2; i++) {
   c = s.charAt(i);
   n = (int)(c & 0xFFFF);
   if (n >= 0xAC00 && n <= 0xD7A3) {
    n = n - 0xAC00;
    n1 = n / (21 * 28);
    n = n % (21 * 28);
    n2 = n / 28;
    n3 = n % 28;

   // 해당 초성 중성 종성 에 맞게 값을 합한다
    tmp=chosung[n1] + moeum[n2] + badchim[n3];

   //자리수 맞추기 위해
    m_value_temp += new DecimalFormat("00000").format(tmp);
   }
   else {

     // 한칸 스페이스 처리
     if((int)c==32) m_value_temp += "00000";

    // 한글 이외의 코드값을 숫자로 변형해서 넣는다 보통 ascill 값정도
    else m_value_temp += (int)c;       
   }
  }
 
  return  value;


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ex) src: 하동군수

     value:1257002931

    올림 차순



정수가 아니라 실수기준이었다면 두글자 이상 수치화 가능


* 스크랫 시 덧글 센스

 

:
Posted by mastar

http://suite.tistory.com/ fs 2007 2 28

import oracle.sql.*;
import oracle.jdbc.driver.*;

~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~


oracle.sql.BLOB blob = ((OracleResultSet)rs).getBLOB(1);

BufferedInputStream bis = new BufferedInputStream(blob.getBinaryStream());

String hwp_file_path=env_var.m_download_dir + "/tmp_file.hwp";

BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(hwp_file_path),4096);

int readBlob = bis.read();
while (readBlob != -1)
{
          bos.write(readBlob);
          readBlob = bis.read();
}
bis.close();
bos.close();
 
~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~



디비에 넣는건 위에꺼 반대로?? ~.~

 

:
Posted by mastar

http://suite.tistory.com/  fs  2007-01-11




사용자가 적은 프로그램을 만들때  Connection Pool ( DBConnectionManager.java ) 같은 걸 궂이 사용 할 필요 없다.

소스만 지저분 해진다.


그래서 간단하게 jsp 단에서 Statement.executeQuery , Statement.executeUpdate 함수를 쉽게 사용 할 수 있도록

 일명: DBClass를 만들어 보았다.




1. 사용법


test_db.jsp


<%@ page import="linuxmaster.*" %>

<%

        String RET_STR="";

        //디비 연결정보 파일(db.conf) 생성자로 아이피 계정 암호...등  
        DBClass sel_db=new DBClass("db.conf");
        RET_STR=sel_db.db_Init("MA_DB"); // 디비 선택하여 연결

        if( RET_STR !="SUCC" ){
                out.println(RET_STR);
                return;
        }


        String INSERT_SQL="insert into USERS(user_id,user_pwd,user_group) values('a1','a2','admin')";

        // StmtExeUpdate 라는 함수를 이용하여 INSERT,DELETE,UPDATE 를 수행

        RET_STR=sel_db.StmtExeUpdate(INSERT_SQL);

        if( RET_STR != "SUCC" ){
                out.println(RET_STR);
                return;
        }

       
        String SEL_SQL="select * from USERS";

        // StmtExeQry 라는 함수를 이용하여 SELECT 함수 수행

        RET_STR=sel_db.StmtExeQry(SEL_SQL);
        if( RET_STR != "SUCC" ){
                out.println(RET_STR);
                return;
        }
        while(sel_db.m_rs.next()){
                out.println(sel_db.m_rs.getString("user_id"));
                out.println("<br>");
        }


2. 소스 (DBClass)

   DBClass.java

     

/*
 * DBObject.java
 *
 * Created on 2007년 1월 9일 (금), 오전 11:54
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

/**
 *
 * @author fs*/


package linuxmaster;


import java.sql.*;
import java.io.InputStream;
import java.util.Properties;


public class DBClass{


        private Statement m_stmt=null;
        private Connection m_con=null;


        //default file "db.conf"
        private String m_conf_file="db.conf";

        public ResultSet m_rs=null;


        public DBClass(String p_conf_file){
                m_conf_file=p_conf_file;
        }


        public String db_Init(String p_DB_NAME){

                // read db.conf
                InputStream is = getClass().getResourceAsStream(m_conf_file);
                Properties dbProps = new Properties();
                try {
                        dbProps.load(is);
                }
                catch (Exception e) {
                        e.printStackTrace();
                        String print_temp="Can't read the db.conf file. Make sure db.conf is in the CLASSPATH";
                        System.out.println(print_temp);
                        return  print_temp;
                }
                //db connect setup
                String url="";
                try {
                        Class.forName(dbProps.getProperty("DB_DRIVERS")).newInstance();
                        //String print_temp="..[DBOject()] Driverloading succeed( \"" + dbProps.getProperty("DBMS_TYPE")+"\" ) ....[OK]";
                        //System.out.println(print_temp);

                        url = "jdbc:mysql://" +
                                dbProps.getProperty("DB_SERVER") +
                                ":" +
                                dbProps.getProperty("DB_PORT") +
                                "/" +
                                p_DB_NAME;


                        // connect db(p_DB_NAME)
                        m_con =  DriverManager.getConnection(url,dbProps.getProperty("DB_USER"),dbProps.getProperty("DB_PASSWORD"));

                        m_stmt = m_con.createStatement();

                }catch (Exception e) {
                        e.printStackTrace();

                        String print_temp="==[Exception - Class.forName]"+ e.toString() ;
                        System.out.println(print_temp);

                        print_temp="[Error]<b> CHECK URL:" +url+" user:"+dbProps.getProperty("DB_USER")+" pwd:"+dbProps.getProperty("DB_PASSWORD")+"</b><p>"+e.toString();
                        System.out.println(print_temp);
                        return print_temp;
                }
                return "SUCC";
        }

        public String StmtExeQry(String p_SQL){

                m_rs=null;
                try {
                        m_rs=m_stmt.executeQuery(p_SQL);
                }catch (SQLException e) {

                        e.printStackTrace();
                        int ret_code = e.getErrorCode();
                        String print_temp="..[SQLException-StmtExeQry()]"+ret_code+e.getMessage()+"<br><b> SQL: "+p_SQL+"</b>";
                        System.out.println(print_temp);
                        return  print_temp;

                }
                return "SUCC";

        }//end of StmtExeQry

        public String StmtExeUpdate(String p_SQL){

                try{
                        m_stmt.executeUpdate(p_SQL);

                }catch (SQLException e){

                        e.printStackTrace();
                        int ret_code = e.getErrorCode();
                        String print_temp="..[SQLException-StmtExeUpdate()]"+ret_code+e.getMessage()+"<br><b> SQL: "+p_SQL+"</b>";
                        System.out.println(print_temp);

                        return  print_temp;
                }
                return "SUCC";

        }//end of StmtExeUpdate

}//end of DBObject
 


3. 컴파일


#!/bin/sh

JAVAC_EXE=`which javac`

WEB_INF_DIR="../../WEB-INF"

CLASSES_DIR=$WEB_INF_DIR/classes
mkdir -p $CLASSES_DIR
#컴파일
echo $JAVAC_EXE -d $CLASSES_DIR DBClass.java 

$JAVAC_EXE -d $CLASSES_DIR DBClass.java 

CONFIG_FILE=$CLASSES_DIR/linuxmaster/db.conf

# 환경파일 생성
cat > $CONFIG_FILE << EOF0
DBMS_TYPE=mysql
DB_DRIVERS=org.gjt.mm.mysql.Driver
DB_SERVER=localhost
DB_PORT=3307
DB_USER=root
DB_PASSWORD=*****

EOF0

#mysql 드라이버 jar 복사 한번만
#LIB_DIR=$WEB_INF_DIR/lib
#mkdir -p $LIB_DIR;
#cp mysql-connector-java-3.1.12-bin.jar  $LIB_DIR


# 톰켓 재시작
cd ../../../../bin
shutdown.sh;startup.sh


* 스크랩시 덧글 센스

:
Posted by mastar

http://suite.tistory.com/

2006 12 20  fs

자바로 스크립트나 바이너리를 실행 시킬때


Process 객체를 사용하는데 이때 실행하다 보면

 =====================================================

      java.io.IOException: Too many open files

        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:84)
        at java.lang.Runtime.execInternal(Native Method)
        at java.lang.Runtime.exec(Runtime.java:566)


      ~~ ~~~
=========================================================


이와 같은 에러 메시지가 나온다.


뭐이런 해결책을 인터넷에 시스템적으로 한프로세스당 파일디스크립터값을 수정한는 것도 있는것같은데

실제로 해보진 않았다.

더 인터넷을 찾아보니 그냥  Process.destroy() 해줘 그냥 초기화 하면  그냥 잘 된다. -.-^


아래는 참고한 구굴링 문서임


http://groups.google.co.kr/group/comp.lang.java.programmer/browse_thread/thread/b18433b07c5c831f/e2757eb8073c7b74?lnk=st&q=Too+many+open+files+Runtime&rnum=1&hl=ko#e2757eb8073c7b74
  Runtime.exec: Too many open files
항목에서 단 1개의 메시지 - 트리로 보기
보낸 사람: Michael - 프로필 보기
날짜: 2000년5월26일(금) 오전12시00분
이메일: "Michael" <mforkh...@cell-loc.com>
그룹스: comp.lang.java.programmer
분류되지 않음
순위:
 
옵션 보기

Hello,

I have a remote object (Admin) bound to a CORBA Naming Service that offers
methods to start and stop my remote Java application (TestImpl) on its local
machine (running Solaris). My local application does a lookup on the Admin
object's interface and makes the suitable method calls to start and stop
TestImpl. This works great until I have restarted TestImpl about 40 times.
Then on the exec() call I get the following exception:

java.io.IOException: Too many open files
 at java.lang.UNIXProcess.forkAndExec(Native Method)
 at java.lang.UNIXProcess.forkAndExec(Compiled Code)
 at java.lang.UNIXProcess.<init>(Compiled Code)
 at java.lang.Runtime.execInternal(Native Method)
 at java.lang.Runtime.execInternal(Compiled Code)
 at java.lang.Runtime.exec(Compiled Code)
 at java.lang.Runtime.exec(Compiled Code)

Apparently the cause is not within my TestImpl code because I was able to
reproduce the problem even when I changed TestImpl into an empty application
(does nothing). So the problem would appear to be related to the exec()
call.

Here is how I start the process:
    ...
    Process process = Runtime.getRuntime().exec(myCmdLine);
    ....

Here is how I stop the process:
    ...
    (shutdown the program via remote shutdown call - causes an exit(0) )
    ...
    try
    {
        process.waitFor();
    }
    catch (Exception ee)
    {
        showError();
    }

    process.destroy();
    process = null;

THANKS a lot in advance for any and all suggestions of what might be wrong.

--
Michael


 

:
Posted by mastar

http://suite.tistory.com/ fs


c의 sprintf 를 자바에서는 1.5부터 String 객체에 포함되어있지만

그이하 버전은 없다?? 그래서 구굴링한결과 PrintfFormat.java(2000 Sun Microsystems)소스를 얻어


http://java.sun.com/developer/technicalArticles/Programming/sprintf/

쉽게 사용할 수 있다


사용법

String []arr_str={"test",3};

String RESULT_STR=new PrintfFormat("ㅋㅋ %s %d"\n").sprintf(arr_str);

:
Posted by mastar


http://linuxmaster.tistory.com
 http://cafe.naver.com/linuxmaster.cafe fs


  자바 큰파일 읽어서 String 에 저장
  첨부파일을 String 담아야 하는 이놈의 첨부파일(TEXT)가 경우 19메가인데..
  일반적인 파일 읽기  reader.readLine() 메소드를 이용하여 String 객체에 누적하도록
  프로그램을 해두고 오늘도 야근 밥을 먹고왔는데로 진척이없다 -.-;;; C 처럼 fread없나 ~.~
  뭐 아무래도 String 객체가 한줄 읽을 때 마다 새로 만들고 가비지 켈렉션을 하는 오버헤드가
  많은 갑다... 그래서 구굴링을 한 결과 StringBuffer를 이용하라~~
 그래서 해보니~ 잠깐 ~ 화장실 갔다 온사이에 끝~~ 역시 검색의 생활화~~ 
 참고로 아래 코드 첨부함

================================================================================================
 StringBuffer buffer = new StringBuffer();
 BufferedReader reader = new BufferedReader(new FileReader(txt_attach_file));
 String tmp_buff="";
 while ((inputLine = reader.readLine()) != null){
        buffer.append(inputLine).append(env_var.m_cr_lf);
 }
 reader.close();
 System.out.println(buffer.toString());


================================================================================================

 Indexing from a big file
항목에서 총 9개의 메시지 - 트리로 보기 
 보낸 사람:  Jon Skeet - 프로필 보기
날짜:  2002년12월26일(목) 오전8시51분
이메일:   Jon Skeet <s...@pobox.com>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 



- 따온 텍스트 숨기기 -
- 따온 텍스트 보기 -

a...@pandora.nospam.be wrote:
> I'll first explain my situation and then you will see what my problem
> is. I have one big text-file from around 1GB and every line in the
> file starts with a name plus some extra information.

> There are 4000 lines in this file and for adding them to a database
> I'll have to search that file about 10.000 times.
> Now I can make an index of that file with only the names and such
> index takes just 100 kb. Then I could search the index-file, find out
> what linenumber it is and pick the line in the big file. But now I'm
> wondering if this goes faster at all. This because the only manner I
> know for going to for example line 1000 in the big file is:


> LineNumberReader in = new LineNumberReader
> (new FileReader("names1.txt"));  
> for (int i=0; i<1000; i++) in.readLine();


> I just read in the 1000 lines.
> Or are there other solutions ? I really hope so ...
> Maybe putting the file into a binary file and index with the name
> where a certain line begins (in bytes). But that'll make it a lot more
> complicated.


When you write your index, instead of writing the line number, write the
position in the file in terms of bytes, then you can seek there.

--
Jon Skeet
s...@pobox.com - http://www.pobox.com/~skeet
If replying to the group, please do not mail me at the same time


회신
 

 보낸 사람:  Michiel Konstapel - 프로필 보기
날짜:  2002년12월26일(목) 오후9시26분
이메일:   "Michiel Konstapel" <a...@me.nl>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 


> >When you write your index, instead of writing the line number, write the
> >position in the file in terms of bytes, then you can seek there.
> And how can I get from the linenumber to the byte where some line
> begins ? Thx for the help


Don't use readLine() but read the file manually, looking for the appropriate
EOL sequence (usually \n for *nix text files, \r\n for Windows and \r for
Mac). Read the file character by character. When you find the end of a line,
store the index of the start of the next one somewhere. I'd go for an array,
using the line number as the array index and the position in the file as the
value. Then, open a RandomAccessFile and you can use seek() to go to the
start of any line you want.
HTH,
Michiel

회신
 

 보낸 사람:  Michiel Konstapel - 프로필 보기
날짜:  2002년12월26일(목) 오후10시03분
이메일:   "Michiel Konstapel" <a...@me.nl>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 


"@did" <a...@pandora.nospam.be> wrote in message


news:hntl0v490rn1e9jmjjk6ijutarortooukr@4ax.com...


> Thx, I think it will become something like that. Except for the array,
> I tried to put only the 4000 names in a Vector and I got the
> "OutOfMemory" exception and I have 512 mb ram.


What exactly are you putting in the vector? 4000 doesn't seem like a lot,
unless they're all big somethings. Note that by default, java only uses 64
MB of RAM. Use the -Xmx command line switch to set the maximum amount it can
use, if needed.
Michiel

회신
 

 보낸 사람:  Hayek - 프로필 보기
날짜:  2002년12월26일(목) 오후10시47분
이메일:   Hayek <haye...@nospam.xs4all.nl>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 


@did wrote:


 >
 > Any help is welcome !!

I will send you a 5 mb dir file,
and a Java program that reads it.


On a pedestrian Celeron 700 WITH 66Mhz bus it reads a
txt file of 5.8 MB in 300 msecs and parses it in 300 msecs.


For your file that would extrapolate to twice 51 seconds.


If you have a 2.1 ghz processor and faster ram, that
would be twice 20 seconds. You might add more ram, or
read the file in more passes.


I've been doing this since the advent of Apple ][ Pascal
in 1982 because the readln()'s, were as horrible slow as
they are still under Java. Not as horrible but
relatively to.. So we looked then for making it faster,
reading in a chunk of file and do the parsing directly
from the bytearray. When I started with Java, I used
immediately the same box of tricks, knowing that it was
interpreted, so was Apple Pascal then. The famous
P-system. There was no hotspot compiler then, but this
piece of code that clearly shows you what it is worth.
It is candiferous. If you do not know what candiferous
means rent the movie "Moulin Rouge".


I am looking forward to 64 bit computing and 12 gig of
ram, and of course 64 bit Java running on an amd Opteron.


Hayek.


--
The small particles wave at
the big stars and get noticed.
:-)


회신
 

 보낸 사람:  Michiel Konstapel - 프로필 보기
날짜:  2002년12월27일(금) 오전1시13분
이메일:   "Michiel Konstapel" <a...@me.nl>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 



- 따온 텍스트 숨기기 -
- 따온 텍스트 보기 -

> >"@did" <a...@pandora.nospam.be> wrote in message
> >news:hntl0v490rn1e9jmjjk6ijutarortooukr@4ax.com...
> >> Thx, I think it will become something like that. Except for the array,
> >> I tried to put only the 4000 names in a Vector and I got the
> >> "OutOfMemory" exception and I have 512 mb ram.

> >What exactly are you putting in the vector? 4000 doesn't seem like a lot,
> >unless they're all big somethings. Note that by default, java only uses
64
> >MB of RAM. Use the -Xmx command line switch to set the maximum amount it
can
> >use, if needed.
> >Michiel


> A name is about 40 characters, and when adding them all(4000) to a
> vector I get the "java.lang.OutOfMemoryError" exception. I'll give it
> a try with command line setting you proposed.


40*4000 = 16K characters, or 32KB of memory. There must be something else
using all that memory. Care to post your code?
Michiel

회신
 

Subject changed: Indexing from a big file - java.zip (0/1)   
 보낸 사람:  Michiel Konstapel - 프로필 보기
날짜:  2002년12월27일(금) 오후12시16분
이메일:   "Michiel Konstapel" <a...@me.nl>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 


"@did" <a...@pandora.nospam.be> wrote in message


news:8kum0v4ppjld4rj1ceadvuqgq4pp439ga6@4ax.com...


> http://studwww.rug.ac.be/~ssteveli/java/java.zip

> This will be better ...


Yup, got it. Let me take a look....
You're right, the cause of the OutOfMemoryError is quite non-obvious but
some things I've read on the newsgroup pointed me in the right (I hope)
direction. This is your file reading loop:

  while(line != null) {
   size = line.length();
   name = line.substring(size-40,size);
   System.out.println(name);
   all.add(name);
   line = in.readLine();
  }


Looks fine. But the line.substring() is tripping you up: your lines are very
long (about 4K characters each) and though you are only interested in 40
characters of each, substring() actually returns a String instance that
*shares* the character array of the original String. That means, that the
whole 8KB (4K characters times 16 bits) of data is actually still referenced
(instead of only 80 bytes), so it can't be garbage collected. In the end
you'll actually have the entire file (64 megs) in memory - of which by
default you only have 64 MB...


The solution is to use the seemingly useless String constructor, new
String(String). What this does is copy the character data to a new,
minimally sized character array, which isn't shared with another instance.
That means that the old 4K characters can be garbage collected. After a
minor modification,


    name = new String(line.substring(size-40,size));


your code works fine, completing in about 15 seconds on my machine (Duron
800).
HTH,
Michiel


회신
 

 보낸 사람:  Michiel Konstapel - 프로필 보기
날짜:  2002년12월28일(토) 오전4시34분
이메일:   "Michiel Konstapel" <a...@me.nl>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 


"@did" <a...@pandora.nospam.be> wrote in message


news:qj8o0vkkn074gbua0kr8ffs6roaiqcnos4@4ax.com...


> It had to be something like that, that the whole string stayed in the
> memory because when I wrote only those names into a file and read it
> from that I file there wasn't any problem. But thx a lot for reaching
> out the solution.


No problem, glad I could help. It's just one of those "you just have to
know" things.
HAND,
Michiel

회신
 

 보낸 사람:  John F. O'Brien - 프로필 보기
날짜:  2002년12월28일(토) 오전10시57분
이메일:   "John F. O'Brien" <jobr...@ticon.net>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 


Would reading into a StringBuffer object (rather than String) have worked?


"Michiel Konstapel" <a...@me.nl> wrote in message


news:5U1P9.1891$T41.2098@amstwist00...


- 따온 텍스트 숨기기 -
- 따온 텍스트 보기 -

> "@did" <a...@pandora.nospam.be> wrote in message
> news:qj8o0vkkn074gbua0kr8ffs6roaiqcnos4@4ax.com...

> > It had to be something like that, that the whole string stayed in the
> > memory because when I wrote only those names into a file and read it
> > from that I file there wasn't any problem. But thx a lot for reaching
> > out the solution.


> No problem, glad I could help. It's just one of those "you just have to
> know" things.
> HAND,
> Michiel


회신
 

 보낸 사람:  Michiel Konstapel - 프로필 보기
날짜:  2002년12월28일(토) 오후2시05분
이메일:   "Michiel Konstapel" <a...@me.nl>
그룹스:   comp.lang.java.programmer
분류되지 않음순위:   
옵션 보기 
회신 | 작성자에게 회신 | 전달 | 인쇄 | 개별 메시지 | 원문 보기 | 불건전 메시지 신고 | 이 작성자의 메시지 찾기 


> "Michiel Konstapel" <a...@me.nl> wrote in message
> news:5U1P9.1891$T41.2098@amstwist00...
> > "@did" <a...@pandora.nospam.be> wrote in message
> > news:qj8o0vkkn074gbua0kr8ffs6roaiqcnos4@4ax.com...

> > > It had to be something like that, that the whole string stayed in the
> > > memory because when I wrote only those names into a file and read it
> > > from that I file there wasn't any problem. But thx a lot for reaching
> > > out the solution.


> > No problem, glad I could help. It's just one of those "you just have to
> > know" things.


"John F. O'Brien" <jobr...@ticon.net> wrote in message
news:auj0fh$gsk$1@galileo.ticon.net...


> Would reading into a StringBuffer object (rather than String) have worked?


No, because readLine() would still have returned a String. Or do you mean
appending each line to a StringBuffer, like

  StringBuffer buffer = new StringBuffer();
  String line = in.readLine();
  while(line != null) {
     size = line.length();
     name = line.substring(size-40,size);
     System.out.println(name);
     // was: all.add(name);
     buffer.append(line).append("\n");
     line = in.readLine();
  }


In that case, yes. StringBuffer.append() copies the characters it appends,
not referencing the appended String. The temporary Strings referenced by
line and name would all be eligible for garbage collection.
Michiel


회신
 

 

 

:
Posted by mastar
2008. 5. 15. 19:48

[JAVA] HTML TAG 테그 제거 용-ILE/LANG-JAVA(JSP)2008. 5. 15. 19:48

http://suite.tistory.com/

// 정규표현식으로 제거
 String.replaceAll("<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>","");


 // 한줄로 할려면 아래 추가
 String.replaceAll("("\r|\n|&nbsp;","");

//html 주석제거
  String.replaceAll("<!--.*-->","");
   

 

:
Posted by mastar

http://suite.tistory.com/  fs


사용자 삽입 이미지


 

대학교 3학년 방학때 세미나를 위해 급조한 ^^; 자바 채팅 프로그램

컴파일 : Dbnet_chat.java , Frame1.java 파일이 존재하는 디렉토리에서
            $>javac Dbnet_chat.java


실행   : $>java Dbnet_chat 실행 하게 되면 위와 같은 화면이 나오면 서버,클라이언트 형태로 채팅을 할수 있다.





 

:
Posted by mastar