Home > other >  IO flow simulation console to upload pictures
IO flow simulation console to upload pictures

Time:11-25

By studying the IO stream we learned how to file some simple operation, such as file created, deleted, renamed, to determine whether a file exists, copy files, change the file path and other related content, since want to manipulate files, so it is important to understand the file path must, which requires us to understand the relative path and the concept of absolute path,
Relative paths: general is relative to the current project under the path
An absolute path: generally begin by drive

This is some knowledge, the file needs to be done on a file of these operations, we will know IO flow about, as shown in the figure below:


Finish see IO flow classification in this picture, we know that the IO flow divided into two major categories of byte stream and the characters of the flow, byte stream and almost exactly the same character flow operation way, the difference between just different operating data unit,
Byte streams: operating unit of data bytes;
Character stream: operating unit of data is a character,

Comprehensive we learn some knowledge about IO stream, let's achieve a simple case:
IO flow simulation console to upload pictures: the path of the tip in the console input image, and then started uploading
First we define is a way to upload pictures, code as shown in the figure below:

Upload pictures after you've written, the rest is call directly to the main method, execution effect as shown in the figure below:


This is the result of uploaded successfully, and determine whether to upload pictures there and whether uploaded pictures of two kinds of circumstances, can go to execute code test,

Above is a simple console simulation of case to upload pictures, through the case master IO flow allows us to better use and do some other functions,
  • Related