java
-
CHAPTER 2. (4) printf란?java/ㄴ CHAPTER 2. 변수 2020. 6. 1. 20:28
★ printf - println은 변수 값을 그대로 출력 (값 변환하지 않고는 다른 형식 출력 불가) => 같은 값이라도 다른 형식으로 출력하려면 printf 사용 - 지시자specifier를 통해 변수 값을 여러 형식으로 변환하여 출력 지시자 : 값을 어떻게 출력할 것인지 지시함 ex. int age = 14; System.out.printf("age:%d", age); // age:14 출력 - 만약 출력값이 2개라면 지시자도 2개 (★ 출력값과 지사자 순서 일치) - 개수 제한 없음 ex. int age = 14; int year = 2020; System.out.printf("age:%d year:%d", age, year); // age:14 year:2020 출력 ★ - 줄바꿈 하려면 지시자..
-
16. serialization - (12) SerializationDemo ( 직렬화 )java/코드 리뷰 2020. 4. 27. 16:53
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 package serialization; import java.io.Serializable; public class User implements Serializable { // 시리얼버전 아이디는 보통 1로 하는 편 private static final l..
-
16. characterstream- (11) ReaderDemo ( 도서 관리 시스템 )java/코드 리뷰 2020. 4. 27. 16:48
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 package characterstream; public class Book { private int no; private String title; private String writer; private String publisher; private int price; public Book() { } public Book(int no, String title, String wr..
-
16. bytestream - (10) FileOutputStreamDemo1 ( 콘솔을 파일에 저장 )java/코드 리뷰 2020. 4. 27. 16:41
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 package bytestream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class FileOutputStreamDemo1 { public static void main(String[] args) throws FileNotFoundException, IOException { FileOutputStream fos = new FileOutputStream("c:/files/sample2.txt"); fos.write('h..
-
16. bytestream - (9) FileInputStreamDemo1 ( 파일을 콘솔에 출력 )java/코드 리뷰 2020. 4. 27. 16:39
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 package bytestream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class FileInputStreamDemo1 { public static void main(String[] args) throws FileNotFoundException, IOException { FileInputStream fis = new FileInputStream("c:/files/sample.txt"); int value1 = fis.read(); int ..
-
16. bytestream - (8) FileCopyDemo8 ( 사진주소 복사 - url 사용 )java/코드 리뷰 2020. 4. 27. 16:33
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package bytestream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import org.apache.commons.io.IOUtils; public class FileCopyDemo8 { public static void main(String[] args) throws IOException { URL url = new URL("https://entertain.v.daum.net/v/20200409091328056"); InputStrea..
-
16. bytestream - (7) FileCopyDemo7 ( 사진파일 복사 - url 사용 )java/코드 리뷰 2020. 4. 27. 16:30
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package bytestream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import org.apache.commons.io.IOUtils; public class FileCopyDemo7 { public static void main(String[] args) throws IOException { URL url = new URL("https://t1.daumcdn.net/news/202004/09/newsen/20200409091328980..
-
16. bytestream - (6) FileCopyDemo6 ( 음악파일 복사 - IOUtils 사용 )java/코드 리뷰 2020. 4. 27. 16:26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 package bytestream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import org.apache.commons.io.IOUtils; public class FileCopyDemo6 { public static void main(String[] args) throws IOException{ FileInputStream fis = new FileInputStream("c:/files/SleepAway.mp3"); FileOutputStream fos = new FileOutpu..