반응형

1. Quick Batch File Compiler (Quick BFC)


1.png
Quick Batch File Compiler (Quick BFC) 는 BAT 파일을 EXE 파일로 변환하는 프로그램 입니다.
특히 프로그램 작업 하다 보면 BAT 파일을 자주 만지게 되는데 BAT 파일의 내용을 감추고 싶을때, 또는 lnk(바로가기) 파일에서 지원 되 지 않는 상대경로를 이용한 프로그램 실행 (Launcher) 을 만들때 유용합니다.





2. 프로그램 구하기


1359DB144B85303A18ED7A
Quick Batch File Compiler 3.2.4.0 (Portable, Registered)




18741C054B8549E55422B7
1. http://rapidshare.com 에서 미등록 사용자는 다운 받기위해 30초를 대기 하셔야 되요. ㅠ_ㅠ
 
2. 무설치 버전은 Windows7 에서 정상 동작 함을 확인 하였습니다.
3. 해당 파일은 저와는 무관한 파일 입니다. (구글링 했어요.)







3. 간단한 사용


<test.bat>

".\..\..\..\..\Program Files\7-Zip\7zFM.exe"

위 내용의 배치 파일을 만듭니다.
해당 내용은 7zFM.exe 파일을 실행하며 이때 7zFM.exe 파일을 test.bat 파일이 위치한 경로로부터 상대경로로 접근합니다.



2.png
Quick BFC 에서 해당 bat 파일을 Open 하고 Build 하는 것 만으로 원하는 exe 파일을 얻을 수 있습니다.
(어때요, 참 쉽죠잉~?)

헌데 만들어진 exe 파일을 실행시켜뜨니 이상합니다.

3.png
에레? cmd 창도 같이 떠버리네요?!!!



4.png
Option 에서 Output EXE type 을 Ghost Application 으로 변경해주고 다시 Build 합니다.
그러면 cmd 창은 뜨지 않을거에요.





4. 생성되는 exe 파일의 icon을 정하고 싶어요


5.png
Embedded Files 탭에서 Application Icon 을 선택하여 줍니다. (Icon 이미지 파일은 ico 파일만을 지원합니다.)
그러고 다시 Build를 하면 아래와 같이 exe 파일의 아이콘이 등록됩니다.

반응형
반응형

아래의 방법들을 사용하면 된다.

1. 한글 2007을 설치하기전에 IE8로 Update 했으면?
   -> IE8 제거 후 -> IE8 재 설치 !
2. 웹사이트 복원오류 -> 아래의 온라인 공격방지를 위해 메모리 보호 사용 체크 해제 !

* 위와 같이 증상이 나타 날때는 도구 -> 인터넷 옵션 -> 고급 탭에 있는 온라인 공격방지를 위해 메모리 보호 사용 체크를 해제 한다
익스플로어를 실행하고, 모 사이트에 들어가려고 했더니

아래와 같은 어처구니 없는 메세지를 띄우는게다.

그리고는 오류페이지로 반복해서 돌아가기만 한다.

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

naver.com[으]로 되돌아 갈 수 없었습니다. 
Internet Explorer가 이 웹 사이트 복원 시도를 중단했습니다. 웹 사이트에서 계속 문제가 발생하는 것으로 보입니다.
   사용자가 할 수 있는 조치: 홈 페이지로 이동
plaync.co.kr[으]로 되돌아 가려 시도 중
   추가 정보

웹 사이트에 오류가 발생하거나 작동이 중단되면 Internet Explorer는 사이트를 복구하려 시도합니다.

무한 반복을 방지하기 위해 두 번 시도한 후 중지합니다.
-------------------------------------------------------------------------------------

 

아놔.. 짜증이...

계란탕 끓일 때 냄비 뚜껑 완전히 닫아두고 끓이다가  부글부글 넘쳐 흘러서 전자렌지에 쏟아지고는 

그대로 식어서 눌어붙은걸 볼 때와 비슷하게...

짜증이 파도처럼 밀려오는구나.

 

이곳저곳 해봤는데, 이건 단순히 사이트문제나 호환성보기 문제가 아니란 생각이 들어서 검색.

원인은 망할 "한글 2007" 을 깔았기 때문이란다. 제기랄.

 

익스8 횽님과 사이가 안좋았는지, 한글 2007을 깔면 익스8에서 저런 젠장맞을 현상이 나오는데,

이걸 해결하려면 아래의 3가지 방법이 있다고 한다.

 

1. 익스 7.0 이하로 다운그레이드

2. 한글 2007의 버젼업데이트(정품일 시)

3. 마이크로소프트에서 패치 다운

(http://www.microsoft.com/downloads/details.aspx?FamilyID=992602d8-d857-41cf-b7b1-527afdc1dc0f&DisplayLang=ko )

 

각종 호환성 패치, 메모리 보안 방지 체크 해제 등 을 해봤으나 안됨.

결국 마소의 패치 한방, 재부팅하니 깔끔하게 사라졌다.

 

ㅡ_ㅡ 아 열받어. 내 시간 ....

 

 윈도우 7 사용자를 위한 팁 추가

 

위의 패치는 윈도우7 용이 없다. 문의 주신 분이 계셔서 한번더 확인해봤으나 역시 없음.  -_-;;;

(현재 본인은 윈도우7 사용중)

 

찾아본 결과, 아래의 방법이 유효하다고 한다.

내용 출처: http://ok-dj.com/132

익스플로러8과 한글2007의 충돌로 인한 문제 발생 해결 방법 - Windows 7 적용 가능


  Windows7의 경우 IE7또는 IE6로의 다운그레이가 불가능하기에 다른 방법이 필요하다. 
  익스플로러8의 도구▶호환성 보기 설정(B) 
  호환성 보기에서 모든 웹 사이트 표시(E)에 체크 표시를 한 후에 닫으면 해결된다.
  Windows7 사용자의 경우는 위 방법을 사용해서 해결해야한다.

익스플로러8과 한글2007의 충돌로 인한 문제 발생 해결 방법 - Windows 7 적용 가능


  위 방법으로도 해결이 되지 않을 경우 한가지 더 셋팅해주는 과정이 필요하다. 
  익스플로러8의 도구▶인터넷 옵션▶고급 탭에 있는 온라인 공격방지를 위해 메모리 보호 사용* 부분에 체크를 해제 한다.


위와 같은 방법으로 고치는 것이 가능하다고 하다.

윈도우 7 사용자 분들에게도 정상적으로 인터넷이 되는 밝은 세상이 오길!

 
출처 : http://blog.naver.com/sshknife?Redirect=Log&logNo=80113033969

반응형
반응형

머...

제우스... 잼나는 프로그램....

변경된 파일이 있으면 인지를 해줘야 하는데... 인지를 정상적으로 못하고...

보통 호스명_servlet_콘테이너명/WEBMain.xml

파일안에

 <encoding>
            <request-encoding>
                <default>EUC-KR</default>
                <forced>EUC-KR</forced>
            </request-encoding>
            <response-encoding>
                <default>EUC-KR</default>
                <forced>EUC-KR</forced>
            </response-encoding>
            <postdata-encoding>
                <default>EUC-KR</default>
                <forced>EUC-KR</forced>
            </postdata-encoding>
        </encoding>

이 옵션을 통해 euc-kr 설정이 가능한데....

쩝... 캐쉬되어 있는것이 있다면 오류가 발생한다....

캐쉬 삭제 -> <jsp-work-dir>/home/jeus5/webhome/test_monitor</jsp-work-dir>

cd /home/jeus5/webhome/test_monitor
rm -rf * 

아래는 JEUSMain.xml 파일안에 command-option 부분에서 응답 헤더를 euc-kr로 주는 방법이다.

 -Djeus.servlet.response.header.encoding=EUC-KR
반응형
반응형

The Zip format is also used in the JAR (Java ARchive) file format, which is a way to collect a group of files into a single compressed file, just like Zip. However, like everything else in Java, JAR files are cross-platform, so you don’t need to worry about platform issues. You can also include audio and image files as well as class files.

JAR files are particularly helpful when you deal with the Internet. Before JAR files, your Web browser would have to make repeated requests of a Web server in order to download all of the files that make up an applet. In addition, each of these files was uncompressed. By combining all of the files for a particular applet into a single JAR file, only one server request is necessary and the transfer is faster because of compression. And each entry in a JAR file can be digitally signed for security (see Chapter 14 for an example of signing).

A JAR file consists of a single file containing a collection of zipped files along with a “manifest” that describes them. (You can create your own manifest file; otherwise, the jar program will do it for you.) You can find out more about JAR manifests in the JDK documentation.

The jar utility that comes with Sun’s JDK automatically compresses the files of your choice. You invoke it on the command line:

jar [options] destination [manifest] inputfile(s)


The options are simply a collection of letters (no hyphen or any other indicator is necessary). Unix/Linux users will note the similarity to the tar options. These are:

c

Creates a new or empty archive.

t

Lists the table of contents.

x

Extracts all files.

x file

Extracts the named file.

f

Says: “I’m going to give you the name of the file.” If you don’t use this, jar assumes that its input will come from standard input, or, if it is creating a file, its output will go to standard output.

m

Says that the first argument will be the name of the user-created manifest file.

v

Generates verbose output describing what jar is doing.

0

Only store the files; doesn’t compress the files (use to create a JAR file that you can put in your classpath).

M

Don’t automatically create a manifest file.

If a subdirectory is included in the files to be put into the JAR file, that subdirectory is automatically added, including all of its subdirectories, etc. Path information is also preserved.

Here are some typical ways to invoke jar:

jar cf myJarFile.jar *.class


This creates a JAR file called myJarFile.jar that contains all of the class files in the current directory, along with an automatically generated manifest file.

jar cmf myJarFile.jar myManifestFile.mf *.class


Like the previous example, but adding a user-created manifest file called myManifestFile.mf.

jar tf myJarFile.jar


Produces a table of contents of the files in myJarFile.jar.

jar tvf myJarFile.jar


Adds the “verbose” flag to give more detailed information about the files in myJarFile.jar.

jar cvf myApp.jar audio classes image


Assuming audio, classes, and image are subdirectories, this combines all of the subdirectories into the file myApp.jar. The “verbose” flag is also included to give extra feedback while the jar program is working.

If you create a JAR file using the 0 (zero) option, that file can be placed in your CLASSPATH:

CLASSPATH="lib1.jar;lib2.jar;"


Then Java can search lib1.jar and lib2.jar for class files.

The jar tool isn’t as useful as a zip utility. For example, you can’t add or update files to an existing JAR file; you can create JAR files only from scratch. Also, you can’t move files into a JAR file, erasing them as they are moved. However, a JAR file created on one platform will be transparently readable by the jar tool on any other platform (a problem that sometimes plagues zip utilities).

As you will see in Chapter 14, JAR files are also used to package JavaBeans.

출처 : http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ314_034.htm

반응형
반응형

Multifile storage with Zip

The library that supports the Zip format is much more extensive. With it you can easily store multiple files, and there’s even a separate class to make the process of reading a Zip file easy. The library uses the standard Zip format so that it works seamlessly with all the tools currently downloadable on the Internet. The following example has the same form as the previous example, but it handles as many command-line arguments as you want. In addition, it shows the use of the Checksum classes to calculate and verify the checksum for the file. There are two Checksum types: Adler32 (which is faster) and CRC32 (which is slower but slightly more accurate).

//: c12:ZipCompress.java
// Uses Zip compression to compress any
// number of files given on the command line.
// {Args: ZipCompress.java}
// {Clean: test.zip}
import com.bruceeckel.simpletest.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;

public class ZipCompress {
  private static Test monitor = new Test();
  // Throw exceptions to console:
  public static void main(String[] args)
  throws IOException {
    FileOutputStream f = new FileOutputStream("test.zip");
    CheckedOutputStream csum =
      new CheckedOutputStream(f, new Adler32());
     ZipOutputStream zos = new ZipOutputStream(csum);
     BufferedOutputStream out =
      new BufferedOutputStream(zos);
    zos.setComment("A test of Java Zipping");
    // No corresponding getComment(), though.
    for(int i = 0; i < args.length; i++) {
      System.out.println("Writing file " + args[i]);
      BufferedReader in =
        new BufferedReader(new FileReader(args[i]));
      zos.putNextEntry(new ZipEntry(args[i]));
      int c;
      while((c = in.read()) != -1)
        out.write(c);
      in.close();
    }
    out.close();
    // Checksum valid only after the file has been closed!
    System.out.println("Checksum: " +
      csum.getChecksum().getValue());
    // Now extract the files:
    System.out.println("Reading file");
    FileInputStream fi = new FileInputStream("test.zip");
    CheckedInputStream csumi =
      new CheckedInputStream(fi, new Adler32());
    ZipInputStream in2 = new ZipInputStream(csumi);
    BufferedInputStream bis = new BufferedInputStream(in2);
    ZipEntry ze;
    while((ze = in2.getNextEntry()) != null) {
      System.out.println("Reading file " + ze);
      int x;
      while((x = bis.read()) != -1)
        System.out.write(x);
    }
    if(args.length == 1)
      monitor.expect(new String[] {
        "Writing file " + args[0],
        "%% Checksum: \\d+",
        "Reading file",
        "Reading file " + args[0]}, args[0]);
    System.out.println("Checksum: " +
      csumi.getChecksum().getValue());
    bis.close();
    // Alternative way to open and read zip files:
    ZipFile zf = new ZipFile("test.zip");
    Enumeration e = zf.entries();
    while(e.hasMoreElements()) {
      ZipEntry ze2 = (ZipEntry)e.nextElement();
      System.out.println("File: " + ze2);
      // ... and extract the data as before
    }
    if(args.length == 1)
      monitor.expect(new String[] {
        "%% Checksum: \\d+",
        "File: " + args[0]
      });
  }
} ///:~


For each file to add to the archive, you must call putNextEntry( ) and pass it a ZipEntry object. The ZipEntry object contains an extensive interface that allows you to get and set all the data available on that particular entry in your Zip file: name, compressed and uncompressed sizes, date, CRC checksum, extra field data, comment, compression method, and whether it’s a directory entry. However, even though the Zip format has a way to set a password, this is not supported in Java’s Zip library. And although CheckedInputStream and CheckedOutputStream support both Adler32 and CRC32 checksums, the ZipEntry class supports only an interface for CRC. This is a restriction of the underlying Zip format, but it might limit you from using the faster Adler32.

To extract files, ZipInputStream has a getNextEntry( ) method that returns the next ZipEntry if there is one. As a more succinct alternative, you can read the file using a ZipFile object, which has a method entries( ) to return an Enumeration to the ZipEntries.

In order to read the checksum, you must somehow have access to the associated Checksum object. Here, a reference to the CheckedOutputStream and CheckedInputStream objects is retained, but you could also just hold onto a reference to the Checksum object.

A baffling method in Zip streams is setComment( ). As shown in ZipCompress.java, you can set a comment when you’re writing a file, but there’s no way to recover the comment in the ZipInputStream. Comments appear to be supported fully on an entry-by-entry basis only via ZipEntry.

Of course, you are not limited to files when using the GZIP or Zip libraries—you can compress anything, including data to be sent through a network connection.

출처 : http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ314_033.htm

반응형

'Language > JAVA' 카테고리의 다른 글

Heap Dump 분석을 통한 Perm Area Memory Leak 원인 진단  (0) 2010.12.14
Java ARchives (JAR)  (0) 2010.11.17
자바 간단한 GZIP 압축 예제  (0) 2010.11.17
자바 파일 압축  (0) 2010.11.17
JAVA File Locking(자바 파일 잠금)  (0) 2010.11.17
반응형

Simple compression with GZIP

The GZIP interface is simple and thus is probably more appropriate when you have a single stream of data that you want to compress (rather than a container of dissimilar pieces of data). Here’s an example that compresses a single file:

//: c12:GZIPcompress.java
// {Args: GZIPcompress.java}
// {Clean: test.gz}
import com.bruceeckel.simpletest.*;
import java.io.*;
import java.util.zip.*;

public class GZIPcompress {
  private static Test monitor = new Test();
  // Throw exceptions to console:
  public static void main(String[] args)
  throws IOException {
    if(args.length == 0) {
      System.out.println(
        "Usage: \nGZIPcompress file\n" +
        "\tUses GZIP compression to compress " +
        "the file to test.gz");
      System.exit(1);
    }
    BufferedReader in = new BufferedReader(
      new FileReader(args[0]));
    BufferedOutputStream out = new BufferedOutputStream(
      new GZIPOutputStream(
        new FileOutputStream("test.gz")));
    System.out.println("Writing file");
    int c;
    while((c = in.read()) != -1)
      out.write(c);
    in.close();
    out.close();
    System.out.println("Reading file");
    BufferedReader in2 = new BufferedReader(
      new InputStreamReader(new GZIPInputStream(
        new FileInputStream("test.gz"))));
    String s;
    while((s = in2.readLine()) != null)
      System.out.println(s);
    monitor.expect(new String[] {
      "Writing file",
      "Reading file"
    }, args[0]);
  }
} ///:~


The use of the compression classes is straightforward; you simply wrap your output stream in a GZIPOutputStream or ZipOutputStream, and your input stream in a GZIPInputStream or ZipInputStream. All else is ordinary I/O reading and writing. This is an example of mixing the char-oriented streams with the byte-oriented streams; in uses the Reader classes, whereas GZIPOutputStream’s constructor can accept only an OutputStream object, not a Writer object. When the file is opened, the GZIPInputStream is converted to a Reader.

출처 : http://www.linuxtopia.org/

반응형
반응형

Compression

The Java I/O library contains classes to support reading and writing streams in a compressed format. These are wrapped around existing I/O classes to provide compression functionality.

These classes are not derived from the Reader and Writer classes, but instead are part of the InputStream and OutputStream hierarchies. This is because the compression library works with bytes, not characters. However, you might sometimes be forced to mix the two types of streams. (Remember that you can use InputStreamReader and OutputStreamWriter to provide easy conversion between one type and another.)

 

Compression class

Function

CheckedInputStream

GetCheckSum( ) produces checksum for any InputStream (not just decompression).

CheckedOutputStream

GetCheckSum( ) produces checksum for any OutputStream (not just compression).

DeflaterOutputStream

Base class for compression classes.

ZipOutputStream

A DeflaterOutputStream that compresses data into the Zip file format.

GZIPOutputStream

A DeflaterOutputStream that compresses data into the GZIP file format.

InflaterInputStream

Base class for decompression classes.

ZipInputStream

An InflaterInputStream that decompresses data that has been stored in the Zip file format.

GZIPInputStream

An InflaterInputStream that decompresses data that has been stored in the GZIP file format.


Although there are many compression algorithms, Zip and GZIP are possibly the most commonly used. Thus you can easily manipulate your compressed data with the many tools available for reading and writing these formats.

출처 : http://www.linuxtopia.org/

반응형
반응형

File locking

File locking, introduced in JDK 1.4, allows you to synchronize access to a file as a shared resource. However, the two threads that contend for the same file may be in different JVMs, or one may be a Java thread and the other some native thread in the operating system. The file locks are visible to other operating system processes because Java file locking maps directly to the native operating system locking facility.

Here is a simple example of file locking.

//: c12:FileLocking.java
// {Clean: file.txt}
import java.io.FileOutputStream;
import java.nio.channels.*;

public class FileLocking {
  public static void main(String[] args) throws Exception {
    FileOutputStream fos= new FileOutputStream("file.txt");
    FileLock fl = fos.getChannel().tryLock();
    if(fl != null) {
      System.out.println("Locked File");
      Thread.sleep(100);
      fl.release();
      System.out.println("Released Lock");
    }
    fos.close();
  }
} ///:~


You get a FileLock on the entire file by calling either tryLock( ) or lock( ) on a FileChannel. (SocketChannel, DatagramChannel, and ServerSocketChannel do not need locking since they are inherently single-process entities; you don’t generally share a network socket between two processes.) tryLock( ) is non-blocking. It tries to grab the lock, but if it cannot (when some other process already holds the same lock and it is not shared), it simply returns from the method call. lock( ) blocks until the lock is acquired, or the thread that invoked lock( ) is interrupted, or the channel on which the lock( ) method is called is closed. A lock is released using FileLock.release( ).

It is also possible to lock a part of the file by using

tryLock(long position, long size, boolean shared)


or

lock(long position, long size, boolean shared)


which locks the region (size - position). The third argument specifies whether this lock is shared.

Although the zero-argument locking methods adapt to changes in the size of a file, locks with a fixed size do not change if the file size changes. If a lock is acquired for a region from position to position+size and the file increases beyond position+size, then the section beyond position+size is not locked. The zero-argument locking methods lock the entire file, even if it grows.

Support for exclusive or shared locks must be provided by the underlying operating system. If the operating system does not support shared locks and a request is made for one, an exclusive lock is used instead. The type of lock (shared or exclusive) can be queried using FileLock.isShared( ).

Locking portions of a mapped file

As mentioned earlier, file mapping is typically used for very large files. One thing that you may need to do with such a large file is to lock portions of it so that other processes may modify unlocked parts of the file. This is something that happens, for example, with a database, so that it can be available to many users at once.

Here’s an example that has two threads, each of which locks a distinct portion of a file:

//: c12:LockingMappedFiles.java
// Locking portions of a mapped file.
// {RunByHand}
// {Clean: test.dat}
import java.io.*;
import java.nio.*;
import java.nio.channels.*;

public class LockingMappedFiles {
  static final int LENGTH = 0x8FFFFFF; // 128 Mb
  static FileChannel fc;
  public static void main(String[] args) throws Exception {
    fc = 
      new RandomAccessFile("test.dat", "rw").getChannel();
    MappedByteBuffer out = 
      fc.map(FileChannel.MapMode.READ_WRITE, 0, LENGTH);
    for(int i = 0; i < LENGTH; i++)
      out.put((byte)'x');
    new LockAndModify(out, 0, 0 + LENGTH/3);
    new LockAndModify(out, LENGTH/2, LENGTH/2 + LENGTH/4);
  }
  private static class LockAndModify extends Thread {
    private ByteBuffer buff;
    private int start, end;
    LockAndModify(ByteBuffer mbb, int start, int end) {
      this.start = start;
      this.end = end;
      mbb.limit(end);
      mbb.position(start);
      buff = mbb.slice();
      start();
    }    
    public void run() {
      try {
        // Exclusive lock with no overlap:
        FileLock fl = fc.lock(start, end, false);
        System.out.println("Locked: "+ start +" to "+ end);
        // Perform modification:
        while(buff.position() < buff.limit() - 1)
          buff.put((byte)(buff.get() + 1));
        fl.release();
        System.out.println("Released: "+start+" to "+ end);
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
  }
} ///:~


The LockAndModify thread class sets up the buffer region and creates a slice( ) to be modified, and in run( ), the lock is acquired on the file channel (you can’t acquire a lock on the buffer—only the channel). The call to lock( ) is very similar to acquiring a threading lock on an object—you now have a “critical section” with exclusive access to that portion of the file.

The locks are automatically released when the JVM exits, or the channel on which it was acquired is closed, but you can also explicitly call release( ) on the FileLock object, as shown here.

출처 : http://www.linuxtopia.org/

반응형
반응형

Memory-mapped files

Memory-mapped files allow you to create and modify files that are too big to bring into memory. With a memory-mapped file, you can pretend that the entire file is in memory and that you can access it by simply treating it as a very large array. This approach greatly simplifies the code you write in order to modify the file. Here’s a small example:

//: c12:LargeMappedFiles.java
// Creating a very large file using mapping.
// {RunByHand}
// {Clean: test.dat}
import java.io.*;
import java.nio.*;
import java.nio.channels.*;

public class LargeMappedFiles {
  static int length = 0x8FFFFFF; // 128 Mb
  public static void main(String[] args) throws Exception {
    MappedByteBuffer out = 
      new RandomAccessFile("test.dat", "rw").getChannel()
      .map(FileChannel.MapMode.READ_WRITE, 0, length);
    for(int i = 0; i < length; i++)
      out.put((byte)'x');
    System.out.println("Finished writing");
    for(int i = length/2; i < length/2 + 6; i++)
      System.out.print((char)out.get(i));
  }
} ///:~


To do both writing and reading, we start with a RandomAccessFile, get a channel for that file, and then call map( ) to produce a MappedByteBuffer, which is a particular kind of direct buffer. Note that you must specify the starting point and the length of the region that you want to map in the file; this means that you have the option to map smaller regions of a large file.

MappedByteBuffer is inherited from ByteBuffer, so it has all of ByteBuffer’s methods. Only the very simple uses of put( ) and get( ) are shown here, but you can also use things like asCharBuffer( ), etc.

The file created with the preceding program is 128 MB long, which is probably larger than the space your OS will allow. The file appears to be accessible all at once because only portions of it are brought into memory, and other parts are swapped out. This way a very large file (up to 2 GB) can easily be modified. Note that the file-mapping facilities of the underlying operating system are used to maximize performance.

Performance

Although the performance of “old” stream I/O has been improved by implementing it with nio, mapped file access tends to be dramatically faster. This program does a simple performance comparison:

//: c12:MappedIO.java
// {Clean: temp.tmp}
import java.io.*;
import java.nio.*;
import java.nio.channels.*;

public class MappedIO {
  private static int numOfInts = 4000000;
  private static int numOfUbuffInts = 200000;
  private abstract static class Tester {
    private String name;
    public Tester(String name) { this.name = name; }
    public long runTest() {
      System.out.print(name + ": ");
      try {
        long startTime = System.currentTimeMillis();
        test();
        long endTime = System.currentTimeMillis();
        return (endTime - startTime);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    public abstract void test() throws IOException;
  }
  private static Tester[] tests = { 
    new Tester("Stream Write") {
      public void test() throws IOException {
        DataOutputStream dos = new DataOutputStream(
          new BufferedOutputStream(
            new FileOutputStream(new File("temp.tmp"))));
        for(int i = 0; i < numOfInts; i++)
          dos.writeInt(i);
        dos.close();
      }
    }, 
    new Tester("Mapped Write") {
      public void test() throws IOException {
        FileChannel fc = 
          new RandomAccessFile("temp.tmp", "rw")
          .getChannel();
        IntBuffer ib = fc.map(
          FileChannel.MapMode.READ_WRITE, 0, fc.size())
          .asIntBuffer();
        for(int i = 0; i < numOfInts; i++)
          ib.put(i);
        fc.close();
      }
    }, 
    new Tester("Stream Read") {
      public void test() throws IOException {
        DataInputStream dis = new DataInputStream(
          new BufferedInputStream(
            new FileInputStream("temp.tmp")));
        for(int i = 0; i < numOfInts; i++)
          dis.readInt();
        dis.close();
      }
    }, 
    new Tester("Mapped Read") {
      public void test() throws IOException {
        FileChannel fc = new FileInputStream(
          new File("temp.tmp")).getChannel();
        IntBuffer ib = fc.map(
          FileChannel.MapMode.READ_ONLY, 0, fc.size())
          .asIntBuffer();
        while(ib.hasRemaining())
          ib.get();
        fc.close();
      }
    }, 
    new Tester("Stream Read/Write") {
      public void test() throws IOException {
        RandomAccessFile raf = new RandomAccessFile(
          new File("temp.tmp"), "rw");
        raf.writeInt(1);
        for(int i = 0; i < numOfUbuffInts; i++) {
          raf.seek(raf.length() - 4);
          raf.writeInt(raf.readInt());
        }
        raf.close();
      }
    }, 
    new Tester("Mapped Read/Write") {
      public void test() throws IOException {
        FileChannel fc = new RandomAccessFile(
          new File("temp.tmp"), "rw").getChannel();
        IntBuffer ib = fc.map(
          FileChannel.MapMode.READ_WRITE, 0, fc.size())
          .asIntBuffer();
        ib.put(0);
        for(int i = 1; i < numOfUbuffInts; i++)
          ib.put(ib.get(i - 1));
        fc.close();
      }
    }
  };
  public static void main(String[] args) {
    for(int i = 0; i < tests.length; i++)
      System.out.println(tests[i].runTest());
  }
} ///:~


As seen in earlier examples in this book, runTest( ) is the Template Method that provides the testing framework for various implementations of test( ) defined in anonymous inner subclasses. Each of these subclasses perform one kind of test, so the test( ) methods also give you a prototype for performing the various I/O activities.

Although a mapped write would seem to use a FileOutputStream, all output in file mapping must use a RandomAccessFile, just as read/write does in the preceding code.

Here’s the output from one run:

Stream Write: 1719
Mapped Write: 359
Stream Read: 750
Mapped Read: 125
Stream Read/Write: 5188
Mapped Read/Write: 16


Note that the test( ) methods include the time for initialization of the various I/O objects, so even though the setup for mapped files can be expensive, the overall gain compared to stream I/O is significant.

출처 : http://www.linuxtopia.org/

반응형
반응형

금일 우연히 인터넷 검색을 하던중...

사실 생각지도 못했지만,

한 PC에서 IE를 재설치하지 않고 여러 버젼으로 구동이 가능하는 프로그램이 있는것을 알았다...

물론 테스트 용이긴하지만,

나와 같이 웹 개발을 하는 사람은 필요로 할것이라 느껴지기에

소개한다.

프로그램 사이트 : http://utilu.com/IECollection/

2010.11.09일 기준으로 1.7.0.4 버젼까지 나왔다.

간략하게 사이트에서 소개하는 내용을 보면...

1. IE(Internet Explorer)는 MS(마이크로소프트)사에서 개발된 브라우져이다.
2. 윈도우 IE는 Trident 렌더 엔진 기반으로 되어있다.
3. Utilu IE Collection 은 각각 독립적으로 실행될 수 있는 여러 IE 버젼을 포함하고 있다. 이것은 웹 개발자에게 유용하다.
4. Utilu IE Collection 은 Microsoft Windows 98, 98 SE, ME, NT 4.0, 2000, XP, 2003, Vista, 2008 and 7 의 32bit 와 64비트(운영체제 지원가능한..)를 지원한다.
5. 아래의 IE 버젼을 지원함
  • Internet Explorer 1.0 (4.40.308)
  • Internet Explorer 1.5 (0.1.0.10)
  • Internet Explorer 2.01 (2.01.046)
  • Internet Explorer 3.0 (3.0.1152)
  • Internet Explorer 3.01 (3.01.2723)
  • Internet Explorer 3.03 (3.03.2925)
  • Internet Explorer 4.01 (4.72.3110.0)
  • Internet Explorer 5.01 (5.00.3314.2100)
  • Internet Explorer 5.5 (5.51.4807.2300)
  • Internet Explorer 6.0 (6.00.2800.1106)
  • Internet Explorer 6.0 (6.00.2900.2180)
  • Internet Explorer 7.0 (7.00.5730.13)
  • Internet Explorer 8.0 (8.00.6001.18702)
  • 6. 호환성 표

    Windows versions
    Internet Explorer versions
    95 98 98
    SE
    ME NT 2000 XP XP
    x64
    2003 2003
    x64
    Vista Vista
    x64
    2008 2008
    x64
    7 7
    x64
    IE 1.0 (4.40.308) Yes No No No Yes No No No No No No No No No No No
    IE 1.5 (0.1.0.10) Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
    IE 2.01 (2.01.046) Yes Yes Yes Yes Yes Yes Yes No Yes No Yes No Yes No Yes No
    IE 3.0 (3.0.1152) Yes Yes Yes Yes Yes Yes Yes No Yes No Yes No Yes No Yes No
    IE 3.01 (3.01.2723) Yes Yes Yes Yes Yes Yes Yes No Yes No Yes No Yes No Yes No
    IE 3.03 (3.03.2925) Yes Yes Yes Yes Yes Yes Yes No Yes No Yes No Yes No Yes No
    IE 4.01 (4.72.3110.0) Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
    IE 5.01 (5.00.3314.2100) Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
    IE 5.5 (5.51.4807.2300) Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
    IE 6.0 (6.00.2800.1106) No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
    IE 6.0 (6.00.2900.2180) No No No No No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
    IE 7.0 (7.00.5730.13) No No No No No No Yes Yes Yes Yes No No No No No No
    IE 7.0 (7.00.6000.16681) No No No No No No No No No No Yes Yes Yes Yes No No
    IE 8.0 (8.00.6001.18702) No No No No No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
    To activate the IE 7.0 render engine in IE 8.0: go to “Tools”, “Developer Tools” (or press F12)
    and then click on the “Browser Mode” menu item and select “Internet Explorer 7”
    to let the Trident render engine of IE 7.0 render the website.
    IE 6.0 (6.00.2900.5512) contains a bug which results in pages opening in the default browser instead of in
    IE 6.0 (6.00.2900.5512). In IE 6.0 (6.00.2800.1106) and IE 6.0 (6.00.2900.2180) this problem does not occur.
    Therefore use these versions of IE 6.0 from Utilu IE Collection instead of IE 6.0 (6.00.2900.5512).


    * 설치할때 IE8 복사 오류가 나는경우가 있다... 별도로 다운받아서 실행하는듯 한데..

    없으면 IE8...-ENU.exe 파일을 찾아서 다운로드뒤 해당폴더에 넣어주고 무시를 실행하면 정상적으로 설치가 된다.



    반응형

    + Recent posts