Microsoft PowerPoint - 알고리즘_3주차_2차시.pptx

Size: px
Start display at page:

Download "Microsoft PowerPoint - 알고리즘_3주차_2차시.pptx"

Transcription

1 3. C++ Stream Input/Output C++ 에서파일 : 바이트의나열 파일의끝에는 End-of-file fil 표시가존재 파일이 open될때stream이생성되며, 파일은 stream의 subclass 로정의 ios istream ostream ifstream iostream ofstream fstream 파일처리 Headers <iostream.h> and <fstream.h> class ifstream - input class ofstream - output class fstream - either input or output 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 25)

2 파일읽기와쓰기 파일에서읽기 파일에출력하기 파일객체생성 ifstream 객체이름 ; 파일객체생성 ofstream 객체이름 ; 파일열기객체이름.open( 파일이름 ); 파일열기객체이름.open( 파일이름 ); if ( 객체이름 ==NULL) 파일열기오류 if ( 객체이름 ==NULL) 파일열기오류 파일작업 객체이름 >> 변수 파일작업 객체이름 << 변수 파일닫기객체이름.close(); 파일닫기객체이름.close(); 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 26)

3 Example #include <iostream> using std::cerr; using std::cin; using std::cout; using std::ios; using std:endl; #include <fstream> // file stream using std::ofstream; // output file stream int main() { ofstream outclientfile; outclientfile.open( "clients.dat", ios::out ); if (!outclientfile ) { cerr << "File could not be opened" << endl; return 0; cout << "Enter the account, name, and balance." << endl << "Enter EOF to end input. n? "; int account; char name[ 30 ]; double balance; while ( cin >> account >> name >> balance ) { return 0; outclientfile << account << ' ' << name << ' ' << balance << endl; cout << "? "; // ofstream destructor closes file 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 27)

4 fstream 클래스 fstream 클래스 = ofstream + ifstream 파일모드정의 : open() 함수의인자로지정 파일모드설명예 ios::in 파일에서읽어오기파일객체.open( 파일이름, ios::in); ios::out 파일에출력하기파일객체.open( 파일이름, ios::out); ios::app 파일에추가하여출력하기파일객체.open( 파일이름, ios::app); ios::trunc ios::binary 파일이이미존재하는경우삭제하고새로운파일로생성하여출력이진파일로처리하기 파일객체.open( 파일이름, ios::trunc); 파일객체.open( 파일이름, ios::in ios::binary); 파일객체.open( 파일이름, ios::out ios::binary); 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 28)

5 File 의 read & write << 나 >> 연산자사용 : text 단위의입출력 read 정해진바이트만큼입력스트림에서 read 사용방법 : integer를읽을경우 ifile.read(reinterpret_cast<char *>(&number), sizeof(int)); First argument: pointer of type char * Second argument: number of bytes to read write 정해진바이트만큼해당메모리주소에서출력스트림에 write 사용방법 : integer 를출력할경우, ofile.write(reinterpret_cast<const char *>(&number), sizeof(int)); First argument: pointer of type const char * Second argument: number of bytes to write 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 29)

6 File 에서읽고쓰는위치변경 seekg (seek get) for istream and seekp (seek put) for ostream fileobject.seekg( n ) 파일의 n 번째바이트로이동 (ios::beg 을가정 ) fileobject.seekg( n, ios::cur ) 현재위치에서 n 바이트앞으로이동 fileobject.seekg( y, ios::end ) 파일의끝에서 y 바이트만큼이동 fileobject.seekg( 0, ios::end ) 파일의끝으로이동 tellg and tellp return current location of pointer location o = fileobject.tellg() //returns long fstream에서는동일한값을가짐 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 30)

7 Example: e:clientdata.h #include <string> using std::string; class ClientData { public: ClientData( int = 0, string = "", string = "", double = ); // constructor void setaccountnumber( int ); int getaccountnumber() const; void setlastname( string ); string getlastname() const; void setfirstname( string ); string getfirstname() const; void setbalance( double ); double getbalance() const; // accessor functions for accountnumber // accessor functions for lastname // accessor functions for firstname // accessor functions for balance private: int accountnumber; char lastname[ 15 ]; char firstname[ 10 ]; double balance; ; 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 31)

8 Example: TransactionProcessing.cpp ocess (1) #include <iostream> using std::cerr; using std::cin; using std::cout; using std::endl; using std::fixed; using std::ios; using std::left; using std::right; using std::showpoint; t #include <fstream> using std::ofstream; using std::ostream; using std::fstream; #include <iomanip> using std::setw; using std::setprecision; #include <cstdlib> using std::exit; #include "ClientData.h" // ClientData class definition int enterchoice(); void createtextfile( fstream& ); void updaterecord( fstream& ); void newrecord( fstream& ); void deleterecord( fstream& ); void outputline( ostream&, const ClientData & ); int getaccount( const char * const ); enum Choices { PRINT = 1, UPDATE, NEW, DELETE, END ; 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 32)

9 Example: TransactionProcessing.cpp ocess (2) int main() { ft fstream inoutcredit( dit(" "credit.dat", ditd t" ios::in i ios::out ); // open for read and write if (!inoutcredit ) { cerr << "File could not be opened." << endl; exit ( 1 ); int choice; // store user choice while ( ( choice = enterchoice() )!= END ) { // enable user to specify action switch ( choice ) { case PRINT: // create text file from record file createtextfile( inoutcredit ); break; case NEW: // create record newrecord( inoutcredit ); break; case UPDATE: // update record updaterecord( inoutcredit ); break; case DELETE: // delete existing record deleterecord( inoutcredit ); break; default: // display error if user does not select valid choice cerr << "Incorrect choice" << endl; break; inoutcredit.clear(); // Clears all error flags including eofbit return 0; 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 33)

10 Example: TransactionProcessing.cpp ocess (3) int enterchoice() { // display available options cout << " nenter your choice" << endl << "1 - store a formatted text file of accounts" << endl << " called "print.txt " p for printing" << endl << "2 - update an account" << endl << "3 - add a new account" << endl << "4 - delete an account" << endl << "5 - end program n? "; int menuchoice; cin >> menuchoice; return menuchoice; // input menu selection from user 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 34)

11 Example: TransactionProcessing.cpp ocess (4) void createtextfile( fstream &readfromfile ) { ofstream outprintfile( tfil ("print.txt", t t" ios::out t) ); // create text t file if (!outprintfile ) { cerr << "File could not be created." << endl; exit( 1 ); outprintfile << left << setw( 10) <<"Account" << setw( 16) <<"Last Name" << setw( 11 ) << "First Name" << right << setw( 10 ) << "Balance" << endl; readfromfile.seekg( 0 ); // set file-position pointer to beginning of readfromfile ClientData client; // read first record from record file readfromfile.read( reinterpret_cast< char * >(&client), sizeof(clientdata)); while (!readfromfile.eof() ) { // copy all records from record file into text file // write single record to text file if ( client.getaccountnumber()!= 0 ) // skip empty records outputline( outprintfile, client ); // read next record from record file readfromfile.read( reinterpret_cast< char * >(&client), sizeof(clientdata)); 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 35)

12 Example: TransactionProcessing.cpp ocess (5) void newrecord( fstream &insertinfile ) { int accountnumber = getaccount( t( "Enter new account number" "); // account # 입력 insertinfile.seekg((accountnumber - 1) * sizeof(clientdata)); ClientData client; // read record from file insertinfile.read(reinterpret_cast<char read(reinterpret *>(&client) >(&client), sizeof(clientdata ); if ( client.getaccountnumber() == 0 ) { char lastname[ 15 ], firstname[ 10 ]; double balance; // 기존에레코드가없을경우, 추가 cout << "Enter lastname, firstname, balance n? "; cin >> setw( 15 ) >> lastname >> setw( 10 ) >> firstname >> balance; client.setlastname( lastname ); client.setfirstname( firstname ); client.setbalance( balance ); client.setaccountnumber( accountnumber ); insertinfile.seekp( ( accountnumber - 1 ) * sizeof( ClientData ) ); insertinfile.write(reinterpret_cast<constconst char *>(&client), sizeof(clientdata)); else // display error if account already exists cerr << "Account #" << accountnumber << " 이미저장됨." << endl; 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 36)

13 Example: TransactionProcessing.cpp ocess (6) void updaterecord( fstream &updatefile ) { int accountnumber = getaccount( t( "Enter account tto update" "); // account # 입력 updatefile.seekg( ( accountnumber - 1 ) * sizeof( ClientData ) ); ClientData client; // read first record from file updatefile.read( reinterpret_cast< char * >( &client ), sizeof( ClientData ) ); if ( client.getaccountnumber()!= 0 ) { // update record, if record exists in file outputline( cout, client ); // display the record cout << " nenter charge (+) or payment (-): "; double transaction; cin >> transaction; // 뭘할지를사용자에게질의 double oldbalance = client.getbalance(); // update record balance client.setbalance( oldbalance + transaction ); outputline( cout, client ); // write updated record over old record in file updatefile.seekp( ( accountnumber - 1)* sizeof( ClientData )); ); updatefile.write( reinterpret_cast< const char * >( &client ), sizeof(clientdata)); else // display error if account does not exist cerr << "Account #" << accountnumber << " has no information." << endl; 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 37)

14 Example: TransactionProcessing.cpp ocess (7) void deleterecord( fstream &deletefromfile ) { int accountnumber = getaccount( t( "Enter account tto delete" "); deletefromfile.seekg( ( accountnumber - 1 ) * sizeof( ClientData ) ); ClientData client; deletefromfile.read( read( reinterpret_cast< char* >( &client ), sizeof( ClientData )); ); if ( client.getaccountnumber()!= 0 ) { // delete record, if record exists in file ClientData blank; // create blank record // replace existing record with blank record deletefromfile.seekp( ( accountnumber - 1 ) * sizeof( ClientData ) ); deletefromfile.write(reinterpret_cast<const char *>(&blank), sizeof(clientdata)); cout << "Account #" << accountnumber << " deleted. n"; else cerr << "Account #" <<accountnumber << " is empty. n"; 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 38)

15 4. Streams and Files at Java Class Hierarchy FileReader/FileWriter i vs. FileInputStream/FileOutputStream 추가적인 Class 들 java.io.randomaccessfile Class Memory-mapped Files 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 39)

16 4.1 Class Hierarchy ( 대표적인것만 ) class java.lang.object class java.io.inputstream class java.io.fileinputstream class java.io.filterinputstream class java.io.bufferedinputstream class java.io.datainputstream (implements java.io.datainput) class java.io.objectinputstream (implements java.io.objectinput, ) class java.io.outputstream class java.io.fileoutputstream class java.io.filteroutputstream class java.io.bufferedoutputstream class java.io.dataoutputstream (implements java.io.dataoutput) class java.io.objectoutputstream (implements java.io.objectoutput, ) class java.io.randomaccessfile (implements java.io.datainput, java.io.dataoutput) class java.io.reader class java.io.bufferedreader class java.io.inputstreamreader class java.io.filereader class java.io.writer class java.io.bufferedwriter class java.io.outputstreamwriter class java.io.filewriter 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 40)

17 4.2 Reader/Writer vs. InputStream/OutputStream (1) FileReader/FileWriter char(unicode) 타입의데이터입출력 예 : FileReader reader = new FileReader("data data.txt txt"); int data = reader.read(); // 오류처리위해 int 반환 if (data!= -1) char ch = (char) data; 여러개의문자를읽을경우 char arr[] = new char[100]; int num = reader.read(arr); close 방법 : reader.close() 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 41)

18 4.2 Reader/Writer vs. InputStream/OutputStream (2) FileInputStream/FileOutputStream byte 타입의데이터입출력 read 와 write member function 은 Reader/Writer 와동일 import java.io.*; class OutputStreamExample1 { public static void main(string args[]) { FileOutputStream out = null; try { out = new FileOutputStream("./output.dat"); byte arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ; for (int cnt = 0; cnt < arr.length; cnt++) out.write(arr[cnt]); catch (IOException ioe) {System.out.println( println(" 파일로출력할수없습니다."); finally { try { out.close(); catch (Exception e) { 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 42)

19 4.3 추가적인 Class 들 Class 이름 Description DataInputStream Java primitive type의데이터 DataOutputStream 입출력 ObjectInputStream ObjectOutputStream BufferedReader BufferedInputStream BufferedWriter BufferedOutputStream Object 단위의데이터입출력 데이터를한꺼번에읽어서버퍼에저장해두는 class 데이터를버퍼에저장한후, 한꺼번에출력하는 class 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 43)

20 DataInputStream/DataOutputStream ataoutputst DataInputStream: byte stream primitive data type DataOutputStream: primitive i i data type byte stream 파일의입출력기능없음 : FileInputStream 등과연동 FileInputStream in1 = new FileInputStream("input input.dat dat"); DataInputStream in2 = new DataInputStream(in1); 주요 member function 들 DataInputStream DataOutputStream byte readbyte() void writebyte(int v) short readshort() void writeshort(int t(i t v) char readchar() void writechar(int v) int readint() void writeint(int v) long readlong() void writelong(long v) float readfloat() void writefloat(float v) double readdouble() void writedouble(double v) boolean readboolean() void writeboolean(boolean v) 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 44)

21 Example: DataOutputStream import java.io.*; class DataOutputExample1 { public static void main(string args[]) { DataOutputStream out = null; try { out = new DataOutputStream(new FileOutputStream("output.dat")); int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ; for (int cnt = 0; cnt < arr.length; cnt++) out.writeint(arr[cnt]); catch (IOException ioe) {System.out.println(" 파일로출력할수없습니다."); finally y{ try { out.close(); catch (Exception e) { 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 45)

22 ObjectInputStream/ObjectOutputStream ea ea ObjectInputStream: stream object ObjectOutputStream: O object stream 파일의입출력기능없음 : FileInputStream 등과연동 FileOutputStream in1 = new FileOutputStream("input input.dat dat"); ObjectOutputStream in2 = new ObjectOutputStream(in1); in2.writeobject(obj); obj가 serializable object일경우에만출력가능 class 선언시 java.io.serializable 을구현하도록선언 직렬화대상 : static이아닌필드들 ( 생성자, 메소드 x) 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 46)

23 Example: e:objectinputstream ea import java.io.*; import java.util.gregoriancalendar; import java.util.calendar; l class ObjectInputExample1 { public static void main(string args[]) { ObjectInputStream in = null; try { in = new ObjectInputStream(new FileInputStream("output.dat")); while (true) { GregorianCalendar calendar = (GregorianCalendar) in.readobject(); int year = calendar.get(calendar.year); int month = calendar.get(calendar.month) + 1; int date = calendar.get(calendar.date); System.out.println(year + "/" + month + "/" + date); catch (FileNotFoundException fnfe) {System.out.println( println(" 파일없음 "); catch (EOFException eofe) { System.out.println(" 끝 "); catch (IOException ioe) {System.out.println(" 파일을읽을수없습니다."); catch (ClassNotFoundException cnfe) {System.out.println(" 해당클래스가없음."); finally { try { in.close(); catch (Exception e) { 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 47)

24 Buffered ed Input(Output)Stream, Reader FileReader, FileWriter, File Input(Output)Stream read/write method 를호출할때마다 disk access 성능저하 Buffered Input(Output)Stream, Reader/Writer disk access 의단위를버퍼크기로제한 FileInputStream in1 = new FileInputStream("input.dat"); BufferedInputStream in2 = new BufferdInputStream(in1, 1024); 두번째인자를생략하면 default 크기의버퍼생성 나머지 member function 들은 FileInputStream 등과동일 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 48)

25 4.4 RandomAccessFile e Class Cass 앞에서보았던 IO class들은순차적인 access만지원 seek() 의개념이없음 RandomAccessFile File 에대한 random access 지원 FileInput(Output)Stream과별개의 class Object 의직속 subclass 로파일처리에관한모든기능들을독자적으로구현 Constructor/Method t th Description RandomAccessFile(String name, String mode) mode: "r" for read, "rw" for read and write long getfilepointer() lseek(fd, 0, 1) void seek(long pos) lseek(fd, pos, 0) long length() lseek(fd, 0, 2) 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 49)

26 Example: RandomAccessAccountRecord ccou eco d import java.io.*; public class RandomAccessAccountRecord A d extends AccountRecord { public static final int SIZE = 72; public void read( RandomAccessFile file ) throws IOException { setaccount(file.readint()); setfirstname(readname(file)); setlastname(readname(file)); setbalance(file.readdouble()); private String readname( RandomAccessFile file ) throws IOException { char name[] = new char[ 15 ], temp; for ( int count = 0; count < name.length; count++ ) { temp = file.readchar(); name[ count ] = temp; return new String( name ).replace( ' 0', ' ' ); public void write( RandomAccessFile file ) throws IOException { file.writeint( getaccount() ); writename( file, getfirstname() ); writename( file, getlastname() ); file.writedouble( getbalance() ); 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 50)

27 Example: RandomAccessFile e (1) import java.io.*; public class FileEditor { RandomAccessFile file; // reference to the file public FileEditor( File filename ) throws IOException { file = new RandomAccessFile(fileName, "rw"); public RandomAccessAccountRecord getrecord( int accountnumber ) throws IllegalArgumentException, gu NumberFormatException, o IOException { RandomAccessAccountRecord record = new RandomAccessAccountRecord(); // seek appropriate record in file file.seek( ( accountnumber - 1 ) * RandomAccessAccountRecord.SIZE ); record.read(file); return record; public void closefile() throws IOException { if ( file!= null ) file.close(); 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 51)

28 Example: RandomAccessFile e (2) public void updaterecord( int accountnumber, String fname, String lname, double bal) throws IllegalArgumentException, IOException { RandomAccessAccountRecord record = getrecord(accountnumber); if ( record.getaccount() == 0 ) throw new IllegalArgumentException( "Account does not exist" ); file.seek( ( accountnumber - 1 ) * RandomAccessAccountRecord.SIZE ); record = new RandomAccessAccountRecord( accountnumber, fname, lname, bal); record.write( file ); public void newrecord( int accountnumber, String fname, String lname, double bal) throws IllegalArgumentException, IOException { RandomAccessAccountRecord record = getrecord( accountnumber ); if ( record.getaccount()!= 0 ) throw new IllegalArgumentException( "Account already exists" ); file.seek( ( accountnumber - 1)* RandomAccessAccountRecord.SIZE ); record = new RandomAccessAccountRecord( accountnumber, fname, lname, bal); record.write( file ); 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 52)

29 4.5 Memory-mapped Files File을 memory 주소에 mapping한후, 배열을액세스하는것처럼 file 을액세스 RandomAccessFile 보다실행시간이매우빠름 사용방법 (java.nio.*, java.nio.channels.* 등이용 ) MappedByteBuffer 의 instance 획득 RandomAccessFile db = new RandomAccessFile("student.dat", "rw"); MappedByteBuffer mbb = db.getchannel().map(filechannel.mapmode.read_write, 0, db.getchannel().size()); // size 대신에파일크기입력가능 MappedByteBuffer의 method를이용하여데이터액세스 mbb.position((student.getid() - 1) * RandomAccessStudentRecord.SIZE); write: mbb.putint(), mbb.putdouble(), mbb.putchar() 등 read: mbb.getint(), mbb.getdouble(), mbb.getchar() 등 영남대학교데이터베이스연구실 Algorithm: Chapter 3 (Page 53)

파일로출력하는작업순서 1. 파일을연다. 2. 파일로자료를쓴다. 3. 파일을닫는다. 파일입출력에사용되는클래스들. FileInputStream, FileOutputStream, FileReader, FileWriter 문자단위로입출력하기 사람이읽을수있는문자로만구성된파일을읽

파일로출력하는작업순서 1. 파일을연다. 2. 파일로자료를쓴다. 3. 파일을닫는다. 파일입출력에사용되는클래스들. FileInputStream, FileOutputStream, FileReader, FileWriter 문자단위로입출력하기 사람이읽을수있는문자로만구성된파일을읽 파일다루기 1 데이터는이곳에서저곳으로흘러간다. - 즉, 데이터는스트림 (stream) 이되어서일렬로이곳에서저곳으로이동한다. - 자바프로그램에서입출력되는모든데이터는스트림형태로주고받는다. 키보드에서입력되는데이터나모니터로출력되는데이터, 파일로부터읽은데이터, 파일로출력하는데이터들도모두스트림형태이다. - 스트림은흐르는방향에따라입력스트림 (input stream) 과출력스트림

More information

<4D F736F F F696E74202D20C1A63234C0E520C0D4C3E2B7C228B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63234C0E520C0D4C3E2B7C228B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 24 장입출력 이번장에서학습할내용 스트림이란? 스트림의분류 바이트스트림 문자스트림 형식입출력 명령어행에서입출력 파일입출력 스트림을이용한입출력에대하여살펴봅시다. 스트림 (stream) 스트림 (stream) 은 순서가있는데이터의연속적인흐름 이다. 스트림은입출력을물의흐름처럼간주하는것이다. 스트림들은연결될수있다. 중간점검문제 1. 자바에서는입출력을무엇이라고추상화하는가?

More information

12-file.key

12-file.key 11 (String).. java.lang.stringbuffer. s String s = "abcd"; s = s + "e"; a b c d e a b c d e ,., "910359,, " "910359" " " " " (token) (token),, (delimiter). java.util.stringtokenizer String s = "910359,,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 2... ( ). ( ). @ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member @ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data @ Program

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 13 장파일처리 1. 스트림의개념을이해한다. 2. 객체지향적인방법을사용하여파일입출력을할수있다. 3. 텍스트파일과이진파일의차이점을이해한다. 4. 순차파일과임의접근파일의차이점을이해한다. 이번장에서만들어볼프로그램 스트림 (stream) 스트림 (stream) 은 순서가있는데이터의연속적인흐름 이다. 스트림은입출력을물의흐름처럼간주하는것이다. 입출력관련클래스들 파일쓰기

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 3 if, if else, if else if, switch case for, while, do while break, continue : System.in, args, JOptionPane for (,, ) @ vs. logic data method variable Data Data Flow (Type), ( ) @ Member field

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 배효철 th1g@nate.com 1 목차 표준입출력 파일입출력 2 표준입출력 표준입력은키보드로입력하는것, 주로 Scanner 클래스를사용. 표준출력은화면에출력하는메소드를사용하는데대표적으로 System.out.printf( ) 를사용 3 표준입출력 표준출력 : System.out.printlf() 4 표준입출력 Example 01 public static void

More information

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 16 강. 파일입출력목차 파일입출력기초 파일입출력모드 텍스트파일과이진파일 이진파일입출력 임의접근 1 /18 16 강. 파일입출력파일입출력기초 파일입출력과정 파일스트림객체생성 파일열기 사용 : 기본적으로표준입출력객체 (cin, cout) 사용방법과동일 파일닫기 파일스트림클래스의종류

More information

Microsoft PowerPoint - 04-UDP Programming.ppt

Microsoft PowerPoint - 04-UDP Programming.ppt Chapter 4. UDP Dongwon Jeong djeong@kunsan.ac.kr http://ist.kunsan.ac.kr/ Dept. of Informatics & Statistics 목차 UDP 1 1 UDP 개념 자바 UDP 프로그램작성 클라이언트와서버모두 DatagramSocket 클래스로생성 상호간통신은 DatagramPacket 클래스를이용하여

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CC0E7B0EDB0FCB8AE5C53746F636B5F4D616E D656E74732E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CC0E7B0EDB0FCB8AE5C53746F636B5F4D616E D656E74732E637070> 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include "QuickSort.h" 7 using namespace std; 8 9 10 Node* Queue[100]; // 추가입력된데이터를저장하기위한 Queue

More information

Network Programming

Network Programming Part 4 자바네트워크프로그래밍 1. Java IO 2. 스레드 (Thread) 클래스의소개 3. Java Socket 1. 자바입출력 Java_source->src->ch11 1.0 I/O Stream

More information

Java

Java Java http://cafedaumnet/pway Chapter 1 1 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength();

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

02 C h a p t e r Java

02 C h a p t e r Java 02 C h a p t e r Java Bioinformatics in J a va,, 2 1,,,, C++, Python, (Java),,, (http://wwwbiojavaorg),, 13, 3D GUI,,, (Java programming language) (Sun Microsystems) 1995 1990 (green project) TV 22 CHAPTER

More information

Microsoft PowerPoint - chap12.ppt [호환 모드]

Microsoft PowerPoint - chap12.ppt [호환 모드] 12 장파일입력과출력 C++ 로시작하는객체지향프로그래밍 1 강의목표 출력에 ofstream(12.2.1) 과입력에 ifstream(12.2.2) 사용. 파일의존재여부테스트 (12.2.3). 파일의끝 (end of file) 테스트 (1224) (12.2.4). 원하는형식으로데이터쓰기 (12.3). getline, get, put 함수를사용하여데이터읽고쓰기 (12.4).

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

C++ Programming

C++ Programming C++ Programming 예외처리 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 예외처리 2 예외처리 예외처리 C++ 의예외처리 예외클래스와객체 3 예외처리 예외를처리하지않는프로그램 int main() int a, b; cout > a >> b; cout

More information

rmi_박준용_final.PDF

rmi_박준용_final.PDF (RMI) - JSTORM http://wwwjstormpekr (RMI)- Document title: Document file name: Revision number: Issued by: Document Information (RMI)- rmi finaldoc Issue Date: Status:

More information

07 자바의 다양한 클래스.key

07 자바의 다양한 클래스.key [ 07 ] . java.lang Object, Math, String, StringBuffer Byte, Short, Integer, Long, Float, Double, Boolean, Character. java.util Random, StringTokenizer Calendar, GregorianCalendar, Date. Collection, List,

More information

C++ Programming

C++ Programming C++ Programming C++ 스타일의입출력 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 C 스타일의입출력 C++ 스타일의입출력 2 C 스타일의입출력 #include C 스타일의입출력 int main() { int a, b, c; printf(" 세개의정수입력 : "); scanf("%d

More information

C++ Programming

C++ Programming C++ Programming 연산자다중정의 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 연산자다중정의 C++ 스타일의문자열 2 연산자다중정의 연산자다중정의 단항연산자다중정의 이항연산자다중정의 cin, cout 그리고 endl C++ 스타일의문자열 3 연산자다중정의 연산자다중정의 (Operator

More information

05-class.key

05-class.key 5 : 2 (method) (public) (private) (interface) 5.1 (Method), (public method) (private method) (constructor), 3 4 5.2 (client). (receiver)., System.out.println("Hello"); (client object) (receiver object)

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

untitled

untitled - -, (insert) (delete) - - (insert) (delete) (top ) - - (insert) (rear) (delete) (front) A A B top A B C top push(a) push(b) push(c) A B top pop() top A B D push(d) top #define MAX_STACK_SIZE 100 int

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 4 (Object) (Class) (Instance) (Method) (Constructor) Memory 1 UML 1 @ & 1 (Real World) (Software World) @ &.. () () @ & 2 (Real World) (Software World) OOA/ Modeling Abstraction Instantiation

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

2002년 2학기 자료구조

2002년 2학기 자료구조 자료구조 (Data Structures) Chapter 1 Basic Concepts Overview : Data (1) Data vs Information (2) Data Linear list( 선형리스트 ) - Sequential list : - Linked list : Nonlinear list( 비선형리스트 ) - Tree : - Graph : (3)

More information

JAVA PROGRAMMING 실습 09. 예외처리

JAVA PROGRAMMING 실습 09. 예외처리 2015 학년도 2 학기 예외? 프로그램실행중에발생하는예기치않은사건 예외가발생하는경우 정수를 0으로나누는경우 배열의크기보다큰인덱스로배열의원소를접근하는경우 파일의마지막부분에서데이터를읽으려고하는경우 예외처리 프로그램에문제를발생시키지않고프로그램을실행할수있게적절한조치를취하는것 자바는예외처리기를이용하여예외처리를할수있는기법제공 자바는예외를객체로취급!! 나뉨수를입력하시오

More information

chap10.PDF

chap10.PDF 10 C++ Hello!! C C C++ C++ C++ 2 C++ 1980 Bell Bjarne Stroustrup C++ C C++ C, C++ C C 3 C C++ (prototype) (type checking) C C++ : C++ 4 C C++ (prototype) (type checking) [ 10-1] #include extern

More information

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt 변수와상수 1 변수란무엇인가? 변수 : 정보 (data) 를저장하는컴퓨터내의특정위치 ( 임시저장공간 ) 메모리, register 메모리주소 101 번지 102 번지 변수의크기에따라 주로 byte 단위 메모리 2 기본적인변수형및변수의크기 변수의크기 해당컴퓨터에서는항상일정 컴퓨터마다다를수있음 short

More information

[ 정보 ] 과학고 R&E 결과보고서 Monte Carlo Method 를이용한 고교배정시뮬레이션 연구기간 : ~ 연구책임자 : 강대욱 ( 전남대전자컴퓨터공학부 ) 지도교사 : 최미경 ( 전남과학고정보 컴퓨터과 ) 참여학생 : 박진명 ( 전

[ 정보 ] 과학고 R&E 결과보고서 Monte Carlo Method 를이용한 고교배정시뮬레이션 연구기간 : ~ 연구책임자 : 강대욱 ( 전남대전자컴퓨터공학부 ) 지도교사 : 최미경 ( 전남과학고정보 컴퓨터과 ) 참여학생 : 박진명 ( 전 [ 정보 ] 과학고 R&E 결과보고서 Monte Carlo Method 를이용한 고교배정시뮬레이션 연구기간 : 2013. 3 ~ 2014. 2 연구책임자 : 강대욱 ( 전남대전자컴퓨터공학부 ) 지도교사 : 최미경 ( 전남과학고정보 컴퓨터과 ) 참여학생 : 박진명 ( 전남과학고 1학년 ) 박수형 ( 전남과학고 1학년 ) 서범수 ( 전남과학고 1학년 ) 김효정

More information

Design Issues

Design Issues 11 COMPUTER PROGRAMMING INHERIATANCE CONTENTS OVERVIEW OF INHERITANCE INHERITANCE OF MEMBER VARIABLE RESERVED WORD SUPER METHOD INHERITANCE and OVERRIDING INHERITANCE and CONSTRUCTOR 2 Overview of Inheritance

More information

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter 파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter 클래스의사용법은다음과같다. PrintWriter writer = new PrintWriter("output.txt");

More information

(Microsoft PowerPoint - 11\300\345.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - 11\300\345.ppt [\310\243\310\257 \270\360\265\345]) 입출력 C++ 의효율적인입출력방법을배워보자. 이장에서다룰내용 1 cin 과 cout 을이용한입출력 2 입출력연산자중복 3 조작자생성 4 파일입출력 01_cin 과 cout 을이용한입출력 포맷입출력 C++ 의표준입출력은 cin, cout 을사용한다. C 의 printf 는함수이므로매번여러인자를입력해줘야하지만, cin/cout 에서는형식을한번만정의하면계속사용할수있다.

More information

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET 135-080 679-4 13 02-3430-1200 1 2 11 2 12 2 2 8 21 Connection 8 22 UniSQLConnection 8 23 8 24 / / 9 3 UniSQL 11 31 OID 11 311 11 312 14 313 16 314 17 32 SET 19 321 20 322 23 323 24 33 GLO 26 331 GLO 26

More information

Modern Javascript

Modern Javascript ES6 - Arrow Function Class Template String Destructuring Default, Rest, Spread let, const for..of Promises Module System Map, Set * Generator * Symbol * * https://babeljs.io/ Babel is a JavaScript compiler.

More information

Microsoft PowerPoint - 03-TCP Programming.ppt

Microsoft PowerPoint - 03-TCP Programming.ppt Chapter 3. - Socket in Java - 목차 소켓소개 자바에서의 프로그램작성방법 주요클래스와메소드 HTTP 프로토콜을이용한예제 에코프로그램 에코프로그램 - EchoServer 에코프로그램 - EchoClient Q/A 1 1 소켓소개 IP,, and Socket 포트 (): 전송계층에서통신을수행하는응용프로그램을찾기위한주소 소켓 (Socket):

More information

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드] - Socket Programming in Java - 목차 소켓소개 자바에서의 TCP 프로그램작성방법 주요클래스와메소드 HTTP 프로토콜을이용한예제 에코프로그램 Q/A 에코프로그램 - EchoServer 에코프로그램 - EchoClient TCP Programming 1 소켓소개 IP, Port, and Socket 포트 (Port): 전송계층에서통신을수행하는응용프로그램을찾기위한주소

More information

Microsoft PowerPoint - 8ÀÏ°_Æ÷ÀÎÅÍ.ppt

Microsoft PowerPoint - 8ÀÏ°_Æ÷ÀÎÅÍ.ppt 포인터 1 포인터란? 포인터 메모리의주소를가지고있는변수 메모리주소 100번지 101번지 102번지 103번지 int theage (4 byte) 변수의크기에따라 주로 byte 단위 주소연산자 : & 변수의주소를반환 메모리 2 #include list 8.1 int main() using namespace std; unsigned short

More information

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx 2018 학년도 1 학기 JAVA 프로그래밍 II 514760-1 2018 년봄학기 5/10/2018 박경신 Lab#1 (ImageTest) Lab#1 은영상파일 (Image) 을읽어서정보를출력 Java Tutorials Lesson: Working with Images https://docs.oracle.com/javase/tutorial/2d/images/index.html

More information

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Microsoft PowerPoint 자바-기본문법(Ch2).pptx 자바기본문법 1. 기본사항 2. 자료형 3. 변수와상수 4. 연산자 1 주석 (Comments) 이해를돕기위한설명문 종류 // /* */ /** */ 활용예 javadoc HelloApplication.java 2 주석 (Comments) /* File name: HelloApplication.java Created by: Jung Created on: March

More information

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어 개나리 연구소 C 언어 노트 (tyback.egloos.com) 프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어먹고 하더라구요. 그래서,

More information

제11장 자바 입출력

제11장 자바 입출력 제11 장자바입출력 Java_surce->src->ch11 I/O Stream gic 자바입출력 2 서버와클라이언트의소켓준비 자바입출력 3 11.1.1 스트림개념 스트림 순서가있고, 길이가정해져있지않은데이터흐름종류 자바입출력 바이트 ( 바이너리, 숫자 ) 텍스트 ( 문자 )...InputStream...OutputputStream...Reader...Writer

More information

신림프로그래머_클린코드.key

신림프로그래머_클린코드.key CLEAN CODE 6 11st Front Dev. Team 6 1. 2. 3. checked exception 4. 5. 6. 11 : 2 4 : java (50%), javascript (35%), SQL/PL-SQL (15%) : Spring, ibatis, Oracle, jquery ? , (, ) ( ) 클린코드를 무시한다면 . 6 1. ,,,!

More information

C프로-3장c03逞풚

C프로-3장c03逞풚 C h a p t e r 03 C++ 3 1 9 4 3 break continue 2 110 if if else if else switch 1 if if if 3 1 1 if 2 2 3 if if 1 2 111 01 #include 02 using namespace std; 03 void main( ) 04 { 05 int x; 06 07

More information

Cluster management software

Cluster management software 자바네트워크프로그래밍 (OCJP 국제공인자격취득중심 ) 충북대학교 최민 기본예제 예외클래스를정의하고사용하는예제 class NewException extends Exception { public class ExceptionTest { static void methoda() throws NewException { System.out.println("NewException

More information

Microsoft PowerPoint - 알고리즘_5주차_1차시.pptx

Microsoft PowerPoint - 알고리즘_5주차_1차시.pptx Basic Idea of External Sorting run 1 run 2 run 3 run 4 run 5 run 6 750 records 750 records 750 records 750 records 750 records 750 records run 1 run 2 run 3 1500 records 1500 records 1500 records run 1

More information

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android 2 xmlns:tools=http://schemas.android. 10 차시파일처리 1 학습목표 내장메모리의파일을처리하는방법을배운다. SD 카드의파일을처리하는방법을배운다. 2 확인해볼까? 3 내장메모리파일처리 1) 학습하기 [ 그림 10-1] 내장메모리를사용한파일처리 2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1

More information

2007_2_project4

2007_2_project4 Programming Methodology Instructor: Kyuseok Shim Project #4: external sort with template Due Date: 0:0 a.m. between 2007-12-2 & 2007-12-3 Introduction 이프로젝트는 C++ 의 template을이용한 sorting algorithm과정렬해야할데이터의크기가

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스, 객체, 메소드 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 필드만있는클래스 텔레비젼 2 예제 1. 필드만있는클래스 3 예제 2. 여러개의객체생성하기 4 5 예제 3. 메소드가추가된클래스 public class Television { int channel; // 채널번호 int volume; // 볼륨 boolean

More information

13주-14주proc.PDF

13주-14주proc.PDF 12 : Pro*C/C++ 1 2 Embeded SQL 3 PRO *C 31 C/C++ PRO *C NOT! NOT AND && AND OR OR EQUAL == = SQL,,, Embeded SQL SQL 32 Pro*C C SQL Pro*C C, C Pro*C, C C 321, C char : char[n] : n int, short, long : float

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 1 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

01-OOPConcepts(2).PDF

01-OOPConcepts(2).PDF Object-Oriented Programming Concepts Tel: 02-824-5768 E-mail: hhcho@selabsoongsilackr? OOP (Object) (Encapsulation) (Message) (Class) (Inheritance) (Polymorphism) (Abstract Class) (Interface) 2 1 + = (Dependency)

More information

(Microsoft PowerPoint - java1-lecture11.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - java1-lecture11.ppt [\310\243\310\257 \270\360\265\345]) 예외와예외클래스 예외처리 514760-1 2016 년가을학기 12/08/2016 박경신 오류의종류 에러 (Error) 하드웨어의잘못된동작또는고장으로인한오류 에러가발생되면 JVM실행에문제가있으므로프로그램종료 정상실행상태로돌아갈수없음 예외 (Exception) 사용자의잘못된조작또는개발자의잘못된코딩으로인한오류 예외가발생되면프로그램종료 예외처리 추가하면정상실행상태로돌아갈수있음

More information

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public Chapter 9 Lab 문제정답 1. public class Circle private double radius; static final double PI=3.141592; // PI 이름으로 3.141592 로초기화된정적상수 (1) public Circle(double r) radius = r; (2) public double getradius() return

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

12 장파일입출력 파일입출력의기초파일열기, 사용하기, 닫기파일입출력모드문자단위파일입출력텍스트파일과이진파일 read, write 함수에의한이진파일입출력임의접근입출력스트림상태입출력연산자오버로딩과파일입출력 C++ 프로그래밍입문

12 장파일입출력 파일입출력의기초파일열기, 사용하기, 닫기파일입출력모드문자단위파일입출력텍스트파일과이진파일 read, write 함수에의한이진파일입출력임의접근입출력스트림상태입출력연산자오버로딩과파일입출력 C++ 프로그래밍입문 12 장파일입출력 파일입출력의기초파일열기, 사용하기, 닫기파일입출력모드문자단위파일입출력텍스트파일과이진파일 read, write 함수에의한이진파일입출력임의접근입출력스트림상태입출력연산자오버로딩과파일입출력 C++ 프로그래밍입문 1. 파일입출력의기초 파일입출력방법 표준입출력객체인 cin, cout에해당하는파일입출력스트림객체만만들수있다면기본적인사용방법은표준입출력과동일파일입출력스트림객체의생성

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

09-Java Input Output

09-Java Input Output JAVA Programming Language JAVA Input/Output 2 (1) (Stream) 2,,,,, 3 (2) InputStream OutputStream, 8 Reader Writer, 16 4 (3) Data Source/Dest. (byte stream) InputStream OutputStream Java Internal (byte,

More information

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++, Level 1은객관식사지선다형으로출제예정 1. 다음은 POST(Post of Sales Terminal) 시스템의한콜레보레이션다이어그램이다. POST 객체의 enteritem(upc, qty) 와 Sale 객체의 makellineitem(spec,qty) 를 Java 또는 C ++, C # 언어로구현하시오. 각메소드구현과관련하여각객체내에필요한선언이있으면선언하시오.

More information

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 15 강. 표준입출력목차 C++ 입출력클래스 입출력형식설정방법 setf, unsetf 멤버함수에의한입출력형식설정 setf 이외의멤버함에의한입출력형식설정 입출력조작자에의한입출력형식설정 문자및문자열입출력멤버함수 문자단위입출력 줄단위입력 입출력스트림상태 string 클래스 complex

More information

Microsoft PowerPoint - Java7.pptx

Microsoft PowerPoint - Java7.pptx HPC & OT Lab. 1 HPC & OT Lab. 2 실습 7 주차 Jin-Ho, Jang M.S. Hanyang Univ. HPC&OT Lab. jinhoyo@nate.com HPC & OT Lab. 3 Component Structure 객체 (object) 생성개념을이해한다. 외부클래스에대한접근방법을이해한다. 접근제어자 (public & private)

More information

슬라이드 1

슬라이드 1 UNIT 16 예외처리 로봇 SW 교육원 3 기 최상훈 학습목표 2 예외처리구문 try-catch-finally 문을사용핛수있다. 프로그램오류 3 프로그램오류의종류 컴파일에러 (compile-time error) : 컴파일실행시발생 럮타임에러 (runtime error) : 프로그램실행시발생 에러 (error) 프로그램코드에의해서해결될수없는심각핚오류 ex)

More information

JAVA PROGRAMMING 실습 08.다형성

JAVA PROGRAMMING 실습 08.다형성 2015 학년도 2 학기 1. 추상메소드 선언은되어있으나코드구현되어있지않은메소드 abstract 키워드사용 메소드타입, 이름, 매개변수리스트만선언 public abstract String getname(); public abstract void setname(string s); 2. 추상클래스 abstract 키워드로선언한클래스 종류 추상메소드를포함하는클래스

More information

PowerPoint Template

PowerPoint Template 1.C 기반의 C++ 스트림입출력 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 스트림입출력 Jong Hyuk Park printf 와 scanf 출력의기본형태 iostream 헤더파일의포함 HelloWorld2.cpp

More information

Microsoft PowerPoint - Chapter 1-rev

Microsoft PowerPoint - Chapter 1-rev 1.C 기반의 C++ part 1 스트림입출력 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 스트림입출력 Jong Hyuk Park printf 와 scanf 출력의기본형태 : 과거스타일! iostream.h 헤더파일의포함

More information

Slide 1

Slide 1 SeoulTech 2011-2 nd 프로그래밍입문 (2) Chapter 12. Stream and File I/O 박종혁교수 (http://www.parkjonghyuk.net) Tel: 970-6702 Email: jhpark1@snut.ac.kr Learning Objectives I/O Streams File I/O Character I/O Stream

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 1,..... @ 1 Green Project 1991 Oak Java 1995. 5 December '90 by Patrick Naughton, Mike Sheridan and James Gosling Embedded in various consumer electronic device 1992. 9. 3 Star 7 1993 www portability

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 System Software Experiment 1 Lecture 5 - Array Spring 2019 Hwansoo Han (hhan@skku.edu) Advanced Research on Compilers and Systems, ARCS LAB Sungkyunkwan University http://arcs.skku.edu/ 1 배열 (Array) 동일한타입의데이터가여러개저장되어있는저장장소

More information

PowerPoint Template

PowerPoint Template 10. 예외처리 대구가톨릭대학교 IT 공학부 소프트웨어공학연구실 목차 2 10.1 개요 10.2 C++ 의예외처리 10.3 Java 의예외처리 10.4 Ada 의예외처리 10.1 예외처리의개요 (1) 3 예외 (exception) 오버플로나언더플로, 0 으로나누기, 배열첨자범위이탈오류와같이프로그램실행중에비정상적으로발생하는사건 예외처리 (exception handling)

More information

ch09

ch09 9 Chapter CHAPTER GOALS B I G J A V A 436 CHAPTER CONTENTS 9.1 436 Syntax 9.1 441 Syntax 9.2 442 Common Error 9.1 442 9.2 443 Syntax 9.3 445 Advanced Topic 9.1 445 9.3 446 9.4 448 Syntax 9.4 454 Advanced

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 자바의입출력스트림에대한이해 2. 텍스트파일입출력 3. 바이너리파일입출력 4. File 클래스로파일속성알아내기 5. 파일복사응용사례 자바의입출력스트림 3 자바의입출력스트림 입출력장치와자바응용프로그램연결 입력스트림 : 입력장치로부터자바프로그램으로데이터를전달하는객체 출력스트림 : 자바프로그램에서출력장치로데이터를보내는객체

More information

Java ...

Java ... 컴퓨터언어 1 Java 제어문 조성일 조건문 : if, switch 어떠한조건을조사하여각기다른명령을실행 if 문, switch 문 if 문 if - else 문형식 if 문형식 if ( 조건식 ) { 명령문 1; 명령문 2;... if ( 조건식 ) { 명령문 1; 명령문 2;... else { 명령문 a; 명령문 b;... 예제 1 정수를입력받아짝수와홀수를판별하는프로그램을작성하시오.

More information

Cluster management software

Cluster management software 자바네트워크프로그래밍 (OCJP 국제공인자격취득중심 ) 충북대학교 최민 File Class File 클래스 파일의읽고쓰기를제외하고파일과디렉토리에대한필요한많은기능등을제공 파일과디렉토리의정보를조사하고, 이들을생성및삭제하는메소드등이 File 클래스에포함 File 클래스의생성자 File(File parent, String child) File(String pathname)

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

More information

Microsoft PowerPoint - additional01.ppt [호환 모드]

Microsoft PowerPoint - additional01.ppt [호환 모드] 1.C 기반의 C++ part 1 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 함수 Jong Hyuk Park 함수오버로딩 (overloading) 함수오버로딩 (function overloading) C++ 언어에서는같은이름을가진여러개의함수를정의가능

More information

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 (   ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각 JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( http://java.sun.com/javase/6/docs/api ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각선의길이를계산하는메소드들을작성하라. 직사각형의가로와세로의길이는주어진다. 대각선의길이는 Math클래스의적절한메소드를이용하여구하라.

More information

Microsoft PowerPoint - 알고리즘_4주차_1차시.pptx

Microsoft PowerPoint - 알고리즘_4주차_1차시.pptx Chapter 4 Fundamental File Structure Concepts Reference: M. J. Folk and B. Zoellick, File Structures, Addison-Wesley (1992). TABLE OF CONTENTSN Field and Record Organization Record Access More about Record

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 3 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

교육자료

교육자료 THE SYS4U DODUMENT Java Reflection & Introspection 2012.08.21 김진아사원 2012 SYS4U I&C All rights reserved. 목차 I. 개념 1. Reflection 이란? 2. Introspection 이란? 3. Reflection 과 Introspection 의차이점 II. 실제사용예 1. Instance의생성

More information

자바-11장N'1-502

자바-11장N'1-502 C h a p t e r 11 java.net.,,., (TCP/IP) (UDP/IP).,. 1 ISO OSI 7 1977 (ISO, International Standards Organization) (OSI, Open Systems Interconnection). 6 1983 X.200. OSI 7 [ 11-1] 7. 1 (Physical Layer),

More information

C 프로그래밍 언어 입문 C 프로그래밍 언어 입문 김명호저 숭실대학교 출판국 머리말..... C, C++, Java, Fortran, Python, Ruby,.. C. C 1972. 40 C.. C. 1999 C99. C99. C. C. C., kmh ssu.ac.kr.. ,. 2013 12 Contents 1장 프로그래밍 시작 1.1 C 10 1.2 12

More information

Microsoft PowerPoint - Chapter 6.ppt

Microsoft PowerPoint - Chapter 6.ppt 6.Static 멤버와 const 멤버 클래스와 const 클래스와 static 연결리스트프로그램예 Jong Hyuk Park 클래스와 const Jong Hyuk Park C 의 const (1) const double PI=3.14; PI=3.1415; // 컴파일오류 const int val; val=20; // 컴파일오류 3 C 의 const (1)

More information

휠세미나3 ver0.4

휠세미나3 ver0.4 andromeda@sparcs:/$ ls -al dev/sda* brw-rw---- 1 root disk 8, 0 2014-06-09 18:43 dev/sda brw-rw---- 1 root disk 8, 1 2014-06-09 18:43 dev/sda1 brw-rw---- 1 root disk 8, 2 2014-06-09 18:43 dev/sda2 andromeda@sparcs:/$

More information

<4D F736F F F696E74202D20C1A63235C0E520B3D7C6AEBFF6C5A920C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63235C0E520B3D7C6AEBFF6C5A920C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 25 장네트워크프로그래밍 이번장에서학습할내용 네트워크프로그래밍의개요 URL 클래스 TCP를이용한통신 TCP를이용한서버제작 TCP를이용한클라이언트제작 UDP 를이용한통신 자바를이용하여서 TCP/IP 통신을이용하는응응프로그램을작성하여봅시다. 서버와클라이언트 서버 (Server): 사용자들에게서비스를제공하는컴퓨터 클라이언트 (Client):

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070> #include "stdafx.h" #include "Huffman.h" 1 /* 비트의부분을뽑아내는함수 */ unsigned HF::bits(unsigned x, int k, int j) return (x >> k) & ~(~0

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 오류처리 손시운 ssw5176@kangwon.ac.kr 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

자바 프로그래밍

자바 프로그래밍 5 (kkman@mail.sangji.ac.kr) (Class), (template) (Object) public, final, abstract [modifier] class ClassName { // // (, ) Class Circle { int radius, color ; int x, y ; float getarea() { return 3.14159

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 오류처리 손시운 ssw5176@kangwon.ac.kr 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

Microsoft PowerPoint - java2-lecture2.ppt [호환 모드]

Microsoft PowerPoint - java2-lecture2.ppt [호환 모드] 스트림 FileIO, Exception Handling 514770 2018 년가을학기 9/17/2018 박경신 자바의스트림 자바스트림은입출력장치와자바응용프로그램연결 입출력장치와프로그램사이의데이터흐름을처리하는소프트웨어모듈 입력스트림 입력장치로부터자바프로그램으로데이터를전달하는소프트웨어모듈 출력스트림 자바프로그램에서출력장치로데이터를보내는소프트웨어모듈 입출력스트림기본단위

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 3 장함수와문자열 1. 함수의기본적인개념을이해한다. 2. 인수와매개변수의개념을이해한다. 3. 함수의인수전달방법 2가지를이해한다 4. 중복함수를이해한다. 5. 디폴트매개변수를이해한다. 6. 문자열의구성을이해한다. 7. string 클래스의사용법을익힌다. 이번장에서만들어볼프로그램 함수란? 함수선언 함수호출 예제 #include using

More information

Interstage5 SOAP서비스 설정 가이드

Interstage5 SOAP서비스 설정 가이드 Interstage 5 Application Server ( Solaris ) SOAP Service Internet Sample Test SOAP Server Application SOAP Client Application CORBA/SOAP Server Gateway CORBA/SOAP Gateway Client INTERSTAGE SOAP Service

More information

Microsoft PowerPoint - 9ÀÏ°_ÂüÁ¶ÀÚ.ppt

Microsoft PowerPoint - 9ÀÏ°_ÂüÁ¶ÀÚ.ppt 참조자 - 참조자란무엇인가? - 참조자는어떻게만들고사용하는가? - 참조자는포인터와무엇이다른가? 1 참조자 (reference) 란? 참조자 : 객체 ( 타겟 ) 에대한다른이름 ( 별칭 ) 참조자의변화는타겟의변화 참조자만들고반드시초기화 참조자생성 형참조연산자 (&) 참조자이름 = 초기화타겟명 모든항목필수 예 ) int &rsomeref = someint ; 참조자에대한주소연산자

More information

C++ Programming

C++ Programming C++ Programming 클래스와데이터추상화 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 객체지향프로그래밍 클래스와객체 2 객체지향프로그래밍 객체지향언어 (Object-Oriented Language) 프로그램을명령어의목록으로보는시각에서벗어나여러개의 독립된단위, 즉 객체 (Object) 들의모임으로파악

More information

Microsoft Word - EEL2 Lab5 예외처리와 스레드.docx

Microsoft Word - EEL2 Lab5 예외처리와 스레드.docx EEL2 LAB Week 5: 상속 ( 보충 ), 예외처리와스레드 1 Consider using the following Card class public class Card private String name; public Card() name = ""; public Card(String n) name = n; public String getname() return

More information

Index Process Specification Data Dictionary

Index Process Specification Data Dictionary Index Process Specification Data Dictionary File Card Tag T-Money Control I n p u t/o u t p u t Card Tag save D e s c r i p t i o n 리더기위치, In/Out/No_Out. File Name customer file write/ company file write

More information

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 8 장클래스와객체 I 이번장에서학습할내용 클래스와객체 객체의일생직접 메소드클래스를 필드작성해 UML 봅시다. QUIZ 1. 객체는 속성과 동작을가지고있다. 2. 자동차가객체라면클래스는 설계도이다. 먼저앞장에서학습한클래스와객체의개념을복습해봅시다. 클래스의구성 클래스 (class) 는객체의설계도라할수있다. 클래스는필드와메소드로이루어진다.

More information

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형 바에 제네릭스(generics)를 도입하기 위한 연구는 이미 8년 전인 1996년부터라고 한다. 실제로 자바에 제네릭스를 도입하 는 몇 가지 방안들이 논문으로 나오기 시작한 것이 1998년 초임을 감 안하면 무려 8년이 지난 후에야 자바 5.0에 전격 채택되었다는 것은 이것이 얼마나 어려운 일이었나 하는 것을 보여준다. 자바의 스펙을 결정하는 표준화 절차인

More information