본문 바로가기

분류 전체보기122

입출력 필터 스트림 package org.example; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main3 { public static void main(String[] args) { try(DataOutputStream dos = new DataOutputStream(new FileOutputStream("main3.dat"))) { dos.writeInt(10); dos.writeDouble(30.4); }catch (Exception e) { e.printStackTrace(); } try(DataInpu.. 2024. 2. 19.
I/O 스트림에 대한 이해 ● 프로그램의 상당 부분은 다음 대상의 입출력과 관련이 있다. 그리고 이들에 대한 자바의 입출력 방식을 가리켜 I/O 모델이라고 한다. 1바이트씩 쓰는게 일반적이다. ● 입출력 스트림 package org.example; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { public Main() { fileWrite(); fileRead(); } private void fileWrite() { // close 를 무조건 해줘야 한다. try { FileOutputStream fos = n.. 2024. 2. 19.
라벨 이용하기 namespace WinFormsApp100 { public partial class Form1 : Form { int y = 10; class Car { public String Name { get; set; } } List list = new List(); public Form1() { InitializeComponent(); //MakeLabel(10, 90, "추가됨"); Car car1 = new Car() { Name = "마이자동차" }; Car car2 = new Car() { Name = "마이2자동차" }; list.Add(car1); list.Add(car2); foreach (Car car in list) { Console.WriteLine(car); MakeLabel(10, y, .. 2024. 2. 16.
시각과 날짜 코드 ● LocalDate , Period package org.example; import java.time.LocalDate; import java.time.Period; public class Main4 { public static void main(String[] args) { LocalDate today = LocalDate.now(); System.out.println(today); LocalDate xmax = LocalDate.of(today.getYear(),12,25); System.out.println(xmax); LocalDate eve = xmax.minusDays(1); System.out.println(eve); Period left = Period.between(today,xmax.. 2024. 2. 16.