OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * File, socket, HTTP, and other I/O support for server applications. | 6 * File, socket, HTTP, and other I/O support for server applications. |
7 * | 7 * |
8 * The IO library is used for Dart server applications, | 8 * The I/O library is used for Dart server applications, |
9 * which run on a stand-alone Dart VM from the command line. | 9 * which run on a stand-alone Dart VM from the command line. |
10 * *This library does not work in browser based applications.* | 10 * *This library does not work in browser-based applications.* |
11 * | 11 * |
12 * This library allows you to work with files, directories, | 12 * This library allows you to work with files, directories, |
13 * sockets, processes, HTTP servers and clients, and more. | 13 * sockets, processes, HTTP servers and clients, and more. |
14 * | |
15 * To use this library in your code: | |
16 * | |
17 * import 'dart:io'; | |
18 * | |
19 * Many operations related to input and output are asynchronous | |
20 * and are handled using [Future]s or [Stream]s, both of which | |
21 * are in the [dart:async] library. | |
Søren Gjesse
2013/12/19 09:44:40
are in -> are defined in
mem
2013/12/19 23:24:24
Done.
| |
22 * | |
23 * ## FileSystemEntity | |
24 * | |
25 * Given a pathname, you can create a [FileSystemEntity] to represent | |
Søren Gjesse
2013/12/19 09:44:40
It is not possible to create a FileSystemEntity ob
mem
2013/12/19 23:24:24
Done.
| |
26 * whatever is at that pathname. | |
27 * Then you can query the FileSystemEntity object to get information | |
28 * using methods such as 'isDirectory', 'isFile', and 'exists'. | |
29 * Because file system access can be slow, these methods | |
Søren Gjesse
2013/12/19 09:44:40
"can be slow" -> involved I/O.
mem
2013/12/19 23:24:24
Done.
| |
30 * are asynchronous and return a Future. | |
31 * | |
32 * FileSystemEntity.isDirectory(myPath).then((isDir) { | |
33 * if (isDir) { | |
34 * print('$myPath is a directory'); | |
35 * } else { | |
36 * print('$myPath is not a directory'); | |
37 * } | |
38 * }); | |
39 * | |
40 * ## File and Directory | |
Søren Gjesse
2013/12/19 09:44:40
Mention Link as well?
mem
2013/12/19 23:24:24
Done.
| |
41 * | |
42 * Each instance of [File] or [Directory] represents a file or | |
43 * directory, respectively, in the native file system. | |
44 * Both File and Directory are subclasses of FileSystemEntity. | |
45 * You can manipulate the file system through objects of these types. | |
46 * For example, you can rename a file or directory: | |
47 * | |
48 * File myFile = new File('myFile.txt'); | |
49 * myFile.rename('yourFile.txt').then((_) { print('file renamed'); }); | |
50 * | |
51 * Many methods provided by the File and Directory classes | |
52 * run asynchronously and return a Future. | |
53 * | |
54 * ## HttpServer | |
Søren Gjesse
2013/12/19 09:44:40
HttpServer -> HttpServer and HttpClient
mem
2013/12/19 23:24:24
Done.
| |
55 * | |
Søren Gjesse
2013/12/19 09:44:40
The classes [HttpServer] and [HttpClient] provides
mem
2013/12/19 23:24:24
Done.
| |
56 * To create an Http server, we recommend that you try using | |
Søren Gjesse
2013/12/19 09:44:40
Start with:
The [HttpServer] class provides the b
mem
2013/12/19 23:24:24
Done.
| |
57 * the [http_server](https://pub.dartlang.org/packages/http_server) | |
58 * pub package, which contains | |
59 * a set of high-level classes that, together with the [HttpServer] class | |
60 * in this library, makes it easy to provide content through HTTP servers. | |
Søren Gjesse
2013/12/19 09:44:40
"easy to provide content through HTTP servers" ->
mem
2013/12/19 23:24:24
Done.
| |
61 * | |
Søren Gjesse
2013/12/19 09:44:40
Shouldnt we have a sub-section for
## WebSocket
mem
2013/12/19 23:24:24
Thanks. It's great to have a more complete list of
mem
2013/12/19 23:24:24
Done.
| |
62 * ## Standard output, error, and input streams | |
63 * | |
64 * This library provides the standard output, error, and input | |
65 * streams, named 'stdout', 'stderr', and 'stdin', respectively. | |
66 * | |
67 * The stdout and stderr streams are both [IOSink]s and have the same set | |
68 * of methods and properties. | |
69 * | |
70 * To write a string to 'stdout': | |
71 * | |
72 * stdout.writeln('Hello, World!'); | |
73 * | |
74 * To write a list of objects to 'stderr': | |
75 * | |
76 * stderr.writeAll([ 'That ', 'is ', 'an ', 'error.', '\n']); | |
77 * | |
78 * The standard input stream is a true [Stream], so it inherits | |
79 * properties and methods from the Stream class. | |
80 * | |
81 * To read text synchronously from the command line | |
82 * (the program blocks waiting for user to type information): | |
83 * | |
84 * String inputText = stdin.readLineSync(); | |
85 * | |
86 * ## Other resources | |
87 * | |
88 * For an introduction to I/O in Dart, see the | |
89 * [dart:io section of the library tour] | |
90 * (https://www.dartlang.org/docs/dart-up-and-running/contents/ch03.html#ch03-da rtio---file-and-socket-io-for-command-line-apps). | |
91 * | |
92 * To learn more about I/O in Dart, refer to the | |
93 * [tutorial about writing command-line apps] | |
94 * (https://www.dartlang.org/docs/tutorials/io/). | |
14 */ | 95 */ |
15 library dart.io; | 96 library dart.io; |
16 | 97 |
17 import 'dart:async'; | 98 import 'dart:async'; |
18 import 'dart:_collection-dev'; | 99 import 'dart:_collection-dev'; |
19 import 'dart:collection' show HashMap, | 100 import 'dart:collection' show HashMap, |
20 HashSet, | 101 HashSet, |
21 LinkedList, | 102 LinkedList, |
22 LinkedListEntry; | 103 LinkedListEntry; |
23 import 'dart:convert'; | 104 import 'dart:convert'; |
(...skipping 24 matching lines...) Expand all Loading... | |
48 part 'platform_impl.dart'; | 129 part 'platform_impl.dart'; |
49 part 'process.dart'; | 130 part 'process.dart'; |
50 part 'socket.dart'; | 131 part 'socket.dart'; |
51 part 'stdio.dart'; | 132 part 'stdio.dart'; |
52 part 'string_transformer.dart'; | 133 part 'string_transformer.dart'; |
53 part 'timer_impl.dart'; | 134 part 'timer_impl.dart'; |
54 part 'secure_socket.dart'; | 135 part 'secure_socket.dart'; |
55 part 'secure_server_socket.dart'; | 136 part 'secure_server_socket.dart'; |
56 part 'websocket.dart'; | 137 part 'websocket.dart'; |
57 part 'websocket_impl.dart'; | 138 part 'websocket_impl.dart'; |
OLD | NEW |