
"์๋ , ์๋ฏธ๊ณ . ๋ฐ ์ ์ฒด ์ด๋ฆ์ ๋ํด ์๋ ค์ค๊ฒ."
"์ด๋ฏธ ์๊ณ ์๋ฏ์ด ํด๋์ค๋ ํจํค์ง์ ์ ์ฅ๋ฉ๋๋ค. ๋ฐ๋ผ์ ํด๋์ค์ ์ ์ฒด ์ด๋ฆ์ ๋ง์นจํ๋ก ๊ตฌ๋ถ๋ ๋ชจ๋ ํจํค์ง์ ์ด๋ฆ๊ณผ ํด๋์ค ์ด๋ฆ์ผ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค. ๋ค์์ ๋ช ๊ฐ์ง ์์ ๋๋ค . "
ํด๋์ค ์ด๋ฆ | ํจํค์ง ์ด๋ฆ | ์ฑ๋ช |
---|---|---|
|
java.lang | java.lang. ๋ |
|
java.io | java.io. FileInputStream |
|
์๋ฐ.์ ํธ | java.util. ๋ฐฐ์ด๋ชฉ๋ก |
|
java.io | java.io. IO์์ธ ; |
"์ฝ๋์์ ํด๋์ค๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ์ ์ฒด ์ด๋ฆ์ ํ์ํด์ผ ํฉ๋๋ค. ์งง์ ์ด๋ฆ, ์ฆ ํด๋์ค ์ด๋ฆ๋ง ์ฌ์ฉํ ์๋ ์์ง๋ง 'ํด๋์ค๋ฅผ ๊ฐ์ ธ์์ผ' ํฉ๋๋ค. ์ฆ, ํด๋์ค๋ฅผ ์ ์ธํ๊ธฐ ์ ์ class, ๊ฐ์ ธ์ค๊ธฐ๋ผ๋ ๋จ์ด ๋ค์ ๊ฐ์ ธ์ค๋ ค๋ ํด๋์ค์ ์ด๋ฆ์ ํ์ํฉ๋๋ค . ๊ธฐ๋ณธ์ ์ผ๋ก java.lang ํจํค์ง์ ํด๋์ค๋ฅผ ๊ฐ์ ธ์ค๋ฏ๋ก ๊ฐ์ ธ์ฌ ํ์๊ฐ ์์ต๋๋ค. ์๋ฅผ ๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ต๋๋ค."
package com.codegym.lesson2;
public class FileCopy2
{
public static void main(String[] args) throws java.io.IOException
{
java.io.FileInputStream fileInputStream =
new java.io.FileInputStream("c:\\data.txt");
java.io.FileOutputStream fileOutputStream =
new java.io.FileOutputStream("c:\\result.txt");
while (fileInputStream.available() > 0)
{
int data = fileInputStream.read();
fileOutputStream.write(data);
}
fileInputStream.close();
fileOutputStream.close();
}
}
"๋ค์์ ์งง์ ์ด๋ฆ์ ์ฌ์ฉํ๋ ์์ ๋๋ค."
package com.codegym.lesson2;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileCopy
{
public static void main(String[] args) throws IOException
{
FileInputStream fileInputStream =
new FileInputStream("c:\\data.txt");
FileOutputStream fileOutputStream =
new FileOutputStream("c:\\result.txt");
while (fileInputStream.available() > 0)
{
int data = fileInputStream.read();
fileOutputStream.write(data);
}
fileInputStream.close();
fileOutputStream.close();
}
}
"์์์ด์."
"์์ฒญ๋."
GO TO FULL VERSION