실행환경

 Desktop

 조립식

 CPU

 Intel(R) Core(TM) i7-3770 3.50GHz

 Memory

 4 GB

 OS

 Window 7 Professional 32bit

 Java

 1.7.0_51

 WebServer

 Apache Tomcat 7.0

 DB

 MySQL 5.6.15


java.io.File 클래스 API

File 클래스는 파일의 내용을 수정하거나 입력하는 클래스가 아니라, 파일이나 디렉토리 자체를 담는 클래스이다.

즉, File 객체는 파일경로명이나 파일명과 비슷한 것으로 생각할 수 있다. 파일에 입력이나 수정을 하려면 File 객체를 FileWriter 또는 FileInputStream 등의 객체에 전달해서 그 객체에서 사용해야 한다.


import java.io.File;

public class FileTest {
	public static void main(String[] args) {
		// File 객체 생성(이미 존재하는 파일)
		File f = new File("FileTest.txt");
		
		// 현재 프로젝트 폴더내에 생성
		File dir = new File("FileTestDir");
		if(dir.mkdir()) {
			// 폴더가 존재하지 않다면
			System.out.println("true");
		} else {
			// 폴더가 존재한다면
			System.out.println("False");
		}
		
		// 파일 또는 디렉토리의 절대 경로명
		System.out.println(f.getAbsolutePath());
		System.out.println(dir.getAbsolutePath());
		
		// 파일 또는 디렉토리 삭제
		boolean deletedCheck = dir.delete();
		System.out.println(deletedCheck != false ? "삭제 성공" : "삭제 실패");
	}
}


'대학 생활 > JAVA' 카테고리의 다른 글

[JAVA] 연산자 우선순위  (0) 2014.05.02
[JAVA] 파일 읽기, 쓰기  (0) 2014.04.16
[JAVA]정적필드, 정적메소드  (0) 2014.03.18
[JAVA] String <-> int, double, float 변환  (0) 2014.02.28

API 이동

public final class PowerManager

java.lang.Object
-> android.os.PowerManager

Class Overview

이 클래스는 장치의 전원 상태를 제어할 수 있게 한다.


장치의 배터리 생명은 이 API를 사용함에 따라 상당한 영향을 받을 것이다. 정말로 필요하지 않는 한 acquire, PowerManager.WakeLock는 사용하지 말고, 가능한 가장 낮은 레벨을 사용하고 그리고 가능한 한 빨리 release하라.


너는 Context.getSystemService()를 호출함으로써 이 클래스의 인스턴스를 얻을수 있다. 


주된 API는 newWakeLock()이다. 그것은 PowerManager.WakeLock 객체를 만들어 준다. 너는 wake lock 객체를 이용해서 장치의 전원상태를 제어하는 메소드들 사용할 수 있다.


예)

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
    wl.acquire();
    // ..screen will stay on during this section..
    wl.release();


The following wake lock levels are defined, with varying effects on system power. 

그 다음으로 wake lock 레벨들은 시스템 전원에 변화하는 효과와 함께 정의된다. 이 레벨들은 상호 배타적이다. - 너는 오직 그것들 중 하나만 명시할지도 모른다.

Flag Value CPU Screen Keyboard
PARTIAL_WAKE_LOCK On* Off Off
SCREEN_DIM_WAKE_LOCK On Dim Off
SCREEN_BRIGHT_WAKE_LOCK On Bright Off
FULL_WAKE_LOCK On Bright Bright

*If you hold a partial wake lock, the CPU will continue to run, regardless of any display timeouts or the state of the screen and even after the user presses the power button. In all other wake locks, the CPU will run, but the user can still put the device to sleep using the power button.


덧붙혀, 너는 오직 화면의 행동에 영향을 주는 두개의 플래그를 추가할 수 있다. 그 플래그들은 PARTIAL_WAKE_LOCK와 같이 사용할때 효과를 얻지 못한다.

Flag Value Description
ACQUIRE_CAUSES_WAKEUP Normal wake locks don't actually turn on the illumination. Instead, they cause the illumination to remain on once it turns on (e.g. from user activity). This flag will force the screen and/or keyboard to turn on immediately, when the WakeLock is acquired. A typical use would be for notifications which are important for the user to see immediately.
ON_AFTER_RELEASE If this flag is set, the user activity timer will be reset when the WakeLock is released, causing the illumination to remain on a bit longer. This can be used to reduce flicker if you are cycling between wake lock conditions.

Any application using a WakeLock must request the android.permission.WAKE_LOCK permission in an <uses-permission> element of the application's manifest.


Summary

Nested Classes
class PowerManager.WakeLock A wake lock is a mechanism to indicate that your application needs to have the device stay on. 
Constants
int ACQUIRE_CAUSES_WAKEUP Wake lock flag: Turn the screen on when the wake lock is acquired.
int FULL_WAKE_LOCK This constant was deprecated in API level 17. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.
int ON_AFTER_RELEASE Wake lock flag: When this wake lock is released, poke the user activity timer so the screen stays on for a little longer.
int PARTIAL_WAKE_LOCK Wake lock level: Ensures that the CPU is running; the screen and keyboard backlight will be allowed to go off.
int SCREEN_BRIGHT_WAKE_LOCK This constant was deprecated in API level 13. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.
int SCREEN_DIM_WAKE_LOCK This constant was deprecated in API level 17. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.
Public Methods
void goToSleep(long time)
Forces the device to go to sleep.
boolean isScreenOn()
Returns whether the screen is currently on. 화면이 현재 켜있는지 반환한다. 
PowerManager.WakeLock newWakeLock(int levelAndFlags, String tag)
Creates a new wake lock with the specified level and flags. 생성한다. 새로운 wake lock
void reboot(String reason)
장치를 재부팅한다.
void userActivity(long when, boolean noChangeLights)
Notifies the power manager that user activity happened.
void wakeUp(long time)
Forces the device to wake up from sleep.


Constants






http://aroundck.tistory.com/48



by the use of... -숙어- ...의 상용(일상적으로 씀)에 따라.

significantly -부사- (영향을 주거나 두드러징 정도로) 상당히[크게]

affected -형용사- 영향을 받은

unless -접속사- ......하지 않는 한

be sure to do something -숙어- (명령문으로 쓰여) 꼭[반드시] ~을 해라

as soon as -- ...하자마자

as soon as possible -숙어- 되도록 빨리

affect one's behavior -숙어- ~의 행동에 영향을 주다.

have no effect -숙어- 효과를 얻지 못하다


+ Recent posts