프로젝트 제작 도중 스프링이 캐릭터를 쳐다봐야 했다.

   

   

   

   

   

이렇게 하니 바로바로 쳐다본다 .

   

ㅎㅇ


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

   

   

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.IOException;

import java.net.URL;

import javax.imageio.ImageIO;

   

try {

           URL url = new URL("http://img.naver.net/static/www/u/2013/0731/nmms_224940510.gif");

           BufferedImage img = ImageIO.read(url);

           File file=new File("C:\\naver.gif");

           ImageIO.write(img, "gif", file);

       } catch (IOException e) {

        e.printStackTrace();

}

   

   

   


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

   

   

   

   

코드실행시 예외(Exception)가 발생하면 다른구문을 실행하는 구문

if를 사용한것보다 간결하고 가독성이 뛰어나고 효율적이라고 ..

   

try{

예외 발생 가능성 있는 구문

}catch( 예외 매개 변수 ){

예외처리구문

}finally{

항상수행할구문

}

   

   


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

   

   

File 클래스는 파일이나 폴더 정보를 관리하기 위한 클래스

   

1. 생성자

   

   

 생성자

설명 

 File(File parent,String child)

부모객체의 하위 폴더가 될 자식을 이용하여 새로운 객체 생성 

File(String pathname)

지정한 경로이름으로 새로운 객체 생성

File(String parent,String child)

상위 부모 폴더와 하위 자식 폴더로 새로운 객체생성

File(URI uri)

uri 를 이용해 객체 생성 

   

   

2. 구분자

운영체제 마다 구분자가 다르다고합니다.

그래서 file 클래스가 적절한 상수를 제공한다고 합니다.

   

   

public  static  final  String  separator 

   

   

separator 은 자바 실행환경에 따라 적절한 디렉터리를 삽입해준다고 합니다.

 File file = new File("D:"+File.separator+"Java"+File.separator+"123.txt");실사용 예  

   

3. 파일 메소드exists() : 해당 파일이나 디렉토리가 존재하는가

mkdir() : 해당 이름의 폴더 생성  마지막 하위 디렉토리만

mkdirs() : 해당 이름의 폴더 생성 여러 하위 디렉토리 포함

renameTo(file) : 이름을 변경

isDirectory() : 디렉토리 인지 확인

isFile() : 파일인지 확인

isHidden() : 숨김 파일인지 확인

canRead() : 읽기 권한이 있는가

canWrite() : 쓰기권한이 있는가

canExecute() : 실행 권한이 있는가

lastModified() : 마지막 변경 시간 리턴

delete() : 삭제

createNewFile() : 해당 이름으로 비어있는 새로운 파일 생성

getAbsolutePath() : 절대경로 반환

getAbsoluteFile() :  절대경로를 사용해 새로 구축된 파일을 반환

getCanonicalPath() : 절대경로 반환 (./.. 인식)

getCanonicalFIle() : 

getName() : 객체의 이름을 string 으로 반환

getPath() : 객체의 이름을 경로를 포함해서 반환

getParent() : 상위폴도의 파일객체의 이름을 가져옴

getParentFilse() : 상위폴더의파일객체를 가져옴

createTempFile(String prefix, String suffix, File directory) : 지정된 디렉토리에 빈 임시파일 생성

deleteOnExit() : 프로그램이 종료될시 파일삭제

length() : 파일의 크기를 가져옵니다

list() : 디렉토리에 있는 파일들을 문자열의 배열에 집어넣음

listFiles() : 디렉토리에 있는 파일들을 객체의 배열에 집어넣음

setExecutable() : 파일을 실행가능하게 설정

setLastModified(time) : 파일을 변경된 것으로 설정

현재 날자로 변경일 변경 >>  new File("aaa.txt").setLastModified(new Date().getTime());

   

   

   

   


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

압축하기 [D 의 1234 폴더에 a 와 b 텍스트 파일 필요.]

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.util.zip.ZipEntry;

import java.util.zip.ZipOutputStream;

   

public class text1 {

 /**

  * @param args

  */

 public static void main(String[] args) {

  // TODO Auto-generated method stub

  // 압축할 파일에 포함시킬 파일들

      String[] files = new String[]{"D:\\1234\\a.txt", "D:\\1234\\b.txt"};

        

      // 파일을 읽기위한 버퍼

      byte[] buf = new byte[1024];

        

      try {

          // 압축파일명

          String zipName = "D:\\1234\\ab.zip";

          ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipName));

        

          // 파일 압축

          for (int i=0; i<files.length; i++) {

              FileInputStream in = new FileInputStream(files[i]);

        

              // 압축 항목추가

              out.putNextEntry(new ZipEntry(files[i]));

        

              // 바이트 전송

              int len;

              while ((len = in.read(buf)) > 0) {

                  out.write(buf, 0, len);

              }

        

              out.closeEntry();

              in.close();

          }

        

          // 압축파일 작성

          out.close();

      } catch (IOException e) {

       e.printStackTrace();

      }

 }

}

   

압축 풀기 [D의 1234 폴더에 ab파일.]

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.OutputStream;

import java.util.zip.ZipEntry;

import java.util.zip.ZipInputStream;

public class unzip{

 public static void main(String[] args) {

  try {

   // 압축파일 열기

   String zipfile = "D:\\1234\\ab.zip";

   ZipInputStream in = new ZipInputStream(new FileInputStream(

     zipfile));

   // 엔트리 취득

   ZipEntry entry = null;

   while ((entry = in.getNextEntry()) != null) {

    System.out.println(entry.getName() + "에 압축을 풉니다.");

    OutputStream out = new FileOutputStream(entry.getName());

    // 버퍼

    byte[] buf = new byte[1024];

    int len;

    while ((len = in.read(buf)) > 0) {

     out.write(buf, 0, len);

    }

      

    in.closeEntry();

    // out닫기

    out.close();

   }

   in.close();

  } catch (IOException e) {

   e.printStackTrace();

  }

 }

}

   

   


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

제공된 숫자가 유한인지 여부를 확인한다.

   

   

이 함수는 괄호안의 값이 NaN, 무한대 외의 값이면 true를 반환, 이두가지의 경우 false를 반환.

   

   


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

이 함수는 매개 변수가 NaN(숫자 아님) 이면 true 를 반환한다.

   

NaN이 아니면 ture 인지 

trace( isNaN("Tree") );

도 true 를 반환한다.

   

   


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

int(최대-최소+1)*rnd+최소

     

이건 왠만한 rnd 함수가 있는곳에서 사용가능하니 암기 필수 ! 

     

0~1사이의 숫자를 생성해주는 rnd 함수일경우 성립되는 공식입니다.

   

출처: <http://13clover.tistory.com/admin/entry/post/?id=76>


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

== 선언 ==

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

==========

     

     

ShellExecute 0, "OPEN", "위치", "형식", vbNullString, 5 '(0)

   

출처: <http://13clover.tistory.com/admin/entry/post/?id=77>

   


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,

선언

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

     

F1 키를 눌렀을경우 메시지 박스 띄우기

     

타이머 인터벌 1000 정도로

     

Private Sub 타이머_Timer()

If GetAsyncKeyState(vbkeyF1) Then '만약 F1을 눌렀을 경우

MsgBox "메시지 박스" '메시지 박스를 띄운다

End If 'If 문 종료

End Sub

     

   

출처: <http://13clover.tistory.com/admin/entry/post/?id=78>

   


WRITTEN BY
미냐브
게임,유머,게임제작 4보단 3

,