CINXE.COM
dart:io library - Dart API
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no"> <meta name="description" content="dart:io library API docs, for the Dart programming language."> <title>dart:io library - Dart API</title> <link rel="canonical" href="https://api.dart.dev/dart-io"> <link rel="preconnect" href="https://fonts.gstatic.com"> <link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" rel="stylesheet"> <link rel="stylesheet" href="../static-assets/github.css?v1"> <link rel="stylesheet" href="../static-assets/styles.css?v1"> <link rel="icon" href="../static-assets/favicon.png?v1"> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-VVQ8908SJ5"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-VVQ8908SJ5'); </script> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preload" href="https://fonts.googleapis.com/css2?family=Google+Sans+Text:wght@400&family=Google+Sans:wght@500&display=swap" as="style"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans+Text:wght@400&family=Google+Sans:wght@500&display=swap"> <link rel="stylesheet" href="https://www.gstatic.com/glue/cookienotificationbar/cookienotificationbar.min.css"> </head> <body data-base-href="../" data-using-base-href="false" class="light-theme"> <div id="overlay-under-drawer"></div> <header id="title"> <span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span> <ol class="breadcrumbs gt-separated dark hidden-xs"> <li><a href="../index.html">Dart</a></li> <li class="self-crumb">dart:io</li> </ol> <div class="self-name">dart:io</div> <form class="search navbar-right" role="search"> <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search..."> </form> <div class="toggle" id="theme-button" title="Toggle brightness"> <label for="theme"> <input type="checkbox" id="theme" value="light-theme"> <span id="dark-theme-button" class="material-symbols-outlined"> dark_mode </span> <span id="light-theme-button" class="material-symbols-outlined"> light_mode </span> </label> </div> </header> <main> <div id="dartdoc-main-content" class="main-content" data-above-sidebar="" data-below-sidebar="dart-io/dart-io-library-sidebar.html"> <div> <div id="external-links" class="btn-group"><a title="View source code" class="source-link" href="https://github.com/dart-lang/sdk/blob/9594995093f642957b780603c6435d9e7a61b923/sdk/lib/io/io.dart#L191"><span class="material-symbols-outlined">description</span></a></div> <h1> <span class="kind-library">dart:io</span> library </h1> </div> <section class="desc markdown"> <p>File, socket, HTTP, and other I/O support for non-web applications.</p> <p><strong>Important:</strong> Browser-based apps can't use this library. Only the following can import and use the dart:io library:</p> <ul> <li>Servers</li> <li>Command-line scripts</li> <li>Flutter mobile apps</li> <li>Flutter desktop apps</li> </ul> <p>This library allows you to work with files, directories, sockets, processes, HTTP servers and clients, and more. Many operations related to input and output are asynchronous and are handled using <a href="../dart-async/Future-class.html">Future</a>s or <a href="../dart-async/Stream-class.html">Stream</a>s, both of which are defined in the <a href="../dart-async/dart-async-library.html">dart:async library</a>.</p> <p>To use the dart:io library in your code:</p> <pre class="language-dart"><code class="language-dart">import 'dart:io'; </code></pre> <p>For an introduction to I/O in Dart, see the <a href="https://dart.dev/guides/libraries/library-tour#dartio">dart:io library tour</a>.</p> <h2 id="file-directory-and-link">File, Directory, and Link</h2> <p>An instance of <a href="../dart-io/File-class.html">File</a>, <a href="../dart-io/Directory-class.html">Directory</a>, or <a href="../dart-io/Link-class.html">Link</a> represents a file, directory, or link, respectively, in the native file system.</p> <p>You can manipulate the file system through objects of these types. For example, you can rename a file or directory:</p> <pre class="language-dart"><code class="language-dart">File myFile = File('myFile.txt'); myFile.rename('yourFile.txt').then((_) => print('file renamed')); </code></pre> <p>Many methods provided by the <a href="../dart-io/File-class.html">File</a>, <a href="../dart-io/Directory-class.html">Directory</a>, and <a href="../dart-io/Link-class.html">Link</a> classes run asynchronously and return a <a href="../dart-async/Future-class.html">Future</a>.</p> <h2 id="filesystementity">FileSystemEntity</h2> <p><a href="../dart-io/File-class.html">File</a>, <a href="../dart-io/Directory-class.html">Directory</a>, and <a href="../dart-io/Link-class.html">Link</a> all extend <a href="../dart-io/FileSystemEntity-class.html">FileSystemEntity</a>. In addition to being the superclass for these classes, FileSystemEntity has a number of static methods for working with paths.</p> <p>To get information about a path, you can use the <a href="../dart-io/FileSystemEntity-class.html">FileSystemEntity</a> static methods such as <a href="../dart-io/FileSystemEntity/isDirectory.html">FileSystemEntity.isDirectory</a>, <a href="../dart-io/FileSystemEntity/isFile.html">FileSystemEntity.isFile</a>, and <a href="../dart-io/FileSystemEntity/exists.html">FileSystemEntity.exists</a>. Because file system access involves I/O, these methods are asynchronous and return a <a href="../dart-async/Future-class.html">Future</a>.</p> <pre class="language-dart"><code class="language-dart">FileSystemEntity.isDirectory(myPath).then((isDir) { if (isDir) { print('$myPath is a directory'); } else { print('$myPath is not a directory'); } }); </code></pre> <h2 id="httpserver-and-httpclient">HttpServer and HttpClient</h2> <p>The classes <a href="../dart-io/HttpClient-class.html">HttpClient</a> and <a href="../dart-io/HttpServer-class.html">HttpServer</a> provide low-level HTTP functionality.</p> <p>Instead of using these classes directly, consider using more developer-friendly and composable APIs found in packages.</p> <p>For HTTP clients, look at <a href="https://pub.dev/packages/http"><code>package:http</code></a>.</p> <p>For HTTP servers, look at <a href="https://dart.dev/tutorials/server/httpserver">Write HTTP servers</a> on <a href="https://dart.dev/">dart.dev</a>.</p> <h2 id="process">Process</h2> <p>The <a href="../dart-io/Process-class.html">Process</a> class provides a way to run a process on the native machine. For example, the following code spawns a process that recursively lists the files under <code>web</code>.</p> <pre class="language-dart"><code class="language-dart">Process.start('ls', ['-R', 'web']).then((process) { stdout.addStream(process.stdout); stderr.addStream(process.stderr); process.exitCode.then(print); }); </code></pre> <p>Using <a href="../dart-io/Process/start.html">Process.start</a> returns a <a href="../dart-async/Future-class.html">Future</a>, which completes with a <a href="../dart-io/Process-class.html">Process</a> object when the process has started. This <a href="../dart-io/Process-class.html">Process</a> object allows you to interact with the process while it is running. Using <a href="../dart-io/Process/run.html">Process.run</a> returns a <a href="../dart-async/Future-class.html">Future</a>, which completes with a <a href="../dart-io/ProcessResult-class.html">ProcessResult</a> object when the spawned process has terminated. This <a href="../dart-io/ProcessResult-class.html">ProcessResult</a> object collects the output and exit code from the process.</p> <p>When using <a href="../dart-io/Process/start.html">Process.start</a>, you need to read all data coming on the <a href="../dart-io/Process/stdout.html">Process.stdout</a> and <a href="../dart-io/Process/stderr.html">Process.stderr</a> streams, otherwise the system resources will not be freed.</p> <h2 id="websocket">WebSocket</h2> <p>The <a href="../dart-io/WebSocket-class.html">WebSocket</a> class provides support for the web socket protocol. This allows full-duplex communications between client and server applications.</p> <p>A web socket server uses a normal HTTP server for accepting web socket connections. The initial handshake is a HTTP request which is then upgraded to a web socket connection. The server upgrades the request using <a href="../dart-io/WebSocketTransformer-class.html">WebSocketTransformer</a> and listens for the data on the returned web socket. For example, here's a mini server that listens for 'ws' data on a WebSocket:</p> <pre class="language-dart"><code class="language-dart">runZoned(() async { var server = await HttpServer.bind('127.0.0.1', 4040); server.listen((HttpRequest req) async { if (req.uri.path == '/ws') { var socket = await WebSocketTransformer.upgrade(req); socket.listen(handleMsg); } }); }, onError: (e) => print("An error occurred.")); </code></pre> <p>The client connects to the <a href="../dart-io/WebSocket-class.html">WebSocket</a> using the <a href="../dart-io/WebSocket/connect.html">WebSocket.connect</a> method and a URI that uses the Web Socket protocol. The client can write to the <a href="../dart-io/WebSocket-class.html">WebSocket</a> with the <a href="../dart-io/WebSocket/add.html">WebSocket.add</a> method. For example,</p> <pre class="language-dart"><code class="language-dart">var socket = await WebSocket.connect('ws://127.0.0.1:4040/ws'); socket.add('Hello, World!'); </code></pre> <p>Check out the <a href="https://github.com/dart-lang/dart-samples/tree/master/html5/web/websockets/basics">websocket_sample</a> app, which uses <a href="../dart-io/WebSocket-class.html">WebSocket</a>s to communicate with a server.</p> <h2 id="socket-and-serversocket">Socket and ServerSocket</h2> <p>Clients and servers use <a href="../dart-io/Socket-class.html">Socket</a>s to communicate using the TCP protocol. Use <a href="../dart-io/ServerSocket-class.html">ServerSocket</a> on the server side and <a href="../dart-io/Socket-class.html">Socket</a> on the client. The server creates a listening socket using the <code>bind()</code> method and then listens for incoming connections on the socket. For example:</p> <pre class="language-dart"><code class="language-dart">ServerSocket.bind('127.0.0.1', 4041) .then((serverSocket) { serverSocket.listen((socket) { socket.transform(utf8.decoder).listen(print); }); }); </code></pre> <p>A client connects a <a href="../dart-io/Socket-class.html">Socket</a> using the <code>connect()</code> method, which returns a <a href="../dart-async/Future-class.html">Future</a>. Using <code>write()</code>, <code>writeln()</code>, or <code>writeAll()</code> are the easiest ways to send data over the socket. For example:</p> <pre class="language-dart"><code class="language-dart">Socket.connect('127.0.0.1', 4041).then((socket) { socket.write('Hello, World!'); }); </code></pre> <p>Besides <a href="../dart-io/Socket-class.html">Socket</a> and <a href="../dart-io/ServerSocket-class.html">ServerSocket</a>, the <a href="../dart-io/RawSocket-class.html">RawSocket</a> and <a href="../dart-io/RawServerSocket-class.html">RawServerSocket</a> classes are available for lower-level access to async socket IO.</p> <h2 id="standard-output-error-and-input-streams">Standard output, error, and input streams</h2> <p>This library provides the standard output, error, and input streams, named <a href="../dart-io/stdout.html">stdout</a>, <a href="../dart-io/stderr.html">stderr</a>, and <a href="../dart-io/stdin.html">stdin</a>, respectively.</p> <p>The <a href="../dart-io/stdout.html">stdout</a> and <a href="../dart-io/stderr.html">stderr</a> streams are both <a href="../dart-io/IOSink-class.html">IOSink</a>s and have the same set of methods and properties.</p> <p>To write a string to <a href="../dart-io/stdout.html">stdout</a>:</p> <pre class="language-dart"><code class="language-dart">stdout.writeln('Hello, World!'); </code></pre> <p>To write a list of objects to <a href="../dart-io/stderr.html">stderr</a>:</p> <pre class="language-dart"><code class="language-dart">stderr.writeAll([ 'That ', 'is ', 'an ', 'error.', '\n']); </code></pre> <p>The standard input stream is a true <a href="../dart-async/Stream-class.html">Stream</a>, so it inherits properties and methods from the <a href="../dart-async/Stream-class.html">Stream</a> class.</p> <p>To read text synchronously from the command line (the program blocks waiting for user to type information):</p> <pre class="language-dart"><code class="language-dart">String? inputText = stdin.readLineSync(); </code></pre> </section> <section class="summary offset-anchor" id="classes"> <h2>Classes</h2> <dl> <dt id="BytesBuilder"> <span class="name "><a href="../dart-typed_data/BytesBuilder-class.html">BytesBuilder</a></span> </dt> <dd> Builds a list of bytes, allowing bytes and lists of bytes to be added at the end. </dd> <dt id="CompressionOptions"> <span class="name "><a href="../dart-io/CompressionOptions-class.html">CompressionOptions</a></span> </dt> <dd> Options controlling compression in a <a href="../dart-io/WebSocket-class.html">WebSocket</a>. </dd> <dt id="ConnectionTask"> <span class="name "><a href="../dart-io/ConnectionTask-class.html">ConnectionTask</a><span class="signature"><<wbr><span class="type-parameter">S</span>></span></span> </dt> <dd> A cancelable connection attempt. </dd> <dt id="ContentType"> <span class="name "><a href="../dart-io/ContentType-class.html">ContentType</a></span> </dt> <dd> A MIME/IANA media type used as the value of the <a href="../dart-io/HttpHeaders/contentTypeHeader-constant.html">HttpHeaders.contentTypeHeader</a> header. </dd> <dt id="Cookie"> <span class="name "><a href="../dart-io/Cookie-class.html">Cookie</a></span> </dt> <dd> Representation of a cookie. For cookies received by the server as Cookie header values only <a href="../dart-io/Cookie/name.html">name</a> and <a href="../dart-io/Cookie/value.html">value</a> properties will be set. When building a cookie for the 'set-cookie' header in the server and when receiving cookies in the client as 'set-cookie' headers all fields can be used. </dd> <dt id="Datagram"> <span class="name "><a href="../dart-io/Datagram-class.html">Datagram</a></span> </dt> <dd> A data packet received by a <a href="../dart-io/RawDatagramSocket-class.html">RawDatagramSocket</a>. </dd> <dt id="Directory"> <span class="name "><a href="../dart-io/Directory-class.html">Directory</a></span> </dt> <dd> A reference to a directory (or <em>folder</em>) on the file system. </dd> <dt id="File"> <span class="name "><a href="../dart-io/File-class.html">File</a></span> </dt> <dd> A reference to a file on the file system. </dd> <dt id="FileLock"> <span class="name "><a href="../dart-io/FileLock-class.html">FileLock</a></span> </dt> <dd> Type of lock when requesting a lock on a file. </dd> <dt id="FileMode"> <span class="name "><a href="../dart-io/FileMode-class.html">FileMode</a></span> </dt> <dd> The modes in which a <a href="../dart-io/File-class.html">File</a> can be opened. </dd> <dt id="FileStat"> <span class="name "><a href="../dart-io/FileStat-class.html">FileStat</a></span> </dt> <dd> The result of calling the POSIX <code>stat()</code> function on a file system object. </dd> <dt id="FileSystemCreateEvent"> <span class="name "><a href="../dart-io/FileSystemCreateEvent-class.html">FileSystemCreateEvent</a></span> </dt> <dd> File system event for newly created file system objects. </dd> <dt id="FileSystemDeleteEvent"> <span class="name "><a href="../dart-io/FileSystemDeleteEvent-class.html">FileSystemDeleteEvent</a></span> </dt> <dd> File system event for deletion of file system objects. </dd> <dt id="FileSystemEntity"> <span class="name "><a href="../dart-io/FileSystemEntity-class.html">FileSystemEntity</a></span> </dt> <dd> The common superclass of <a href="../dart-io/File-class.html">File</a>, <a href="../dart-io/Directory-class.html">Directory</a>, and <a href="../dart-io/Link-class.html">Link</a>. </dd> <dt id="FileSystemEntityType"> <span class="name "><a href="../dart-io/FileSystemEntityType-class.html">FileSystemEntityType</a></span> </dt> <dd> The type of an entity on the file system, such as a file, directory, or link. </dd> <dt id="FileSystemEvent"> <span class="name "><a href="../dart-io/FileSystemEvent-class.html">FileSystemEvent</a></span> </dt> <dd> Base event class emitted by <a href="../dart-io/FileSystemEntity/watch.html">FileSystemEntity.watch</a>. </dd> <dt id="FileSystemModifyEvent"> <span class="name "><a href="../dart-io/FileSystemModifyEvent-class.html">FileSystemModifyEvent</a></span> </dt> <dd> File system event for modifications of file system objects. </dd> <dt id="FileSystemMoveEvent"> <span class="name "><a href="../dart-io/FileSystemMoveEvent-class.html">FileSystemMoveEvent</a></span> </dt> <dd> File system event for moving of file system objects. </dd> <dt id="GZipCodec"> <span class="name "><a href="../dart-io/GZipCodec-class.html">GZipCodec</a></span> </dt> <dd> The <a href="../dart-io/GZipCodec-class.html">GZipCodec</a> encodes raw bytes to GZip compressed bytes and decodes GZip compressed bytes to raw bytes. </dd> <dt id="HeaderValue"> <span class="name "><a href="../dart-io/HeaderValue-class.html">HeaderValue</a></span> </dt> <dd> Representation of a header value in the form: </dd> <dt id="HttpClient"> <span class="name "><a href="../dart-io/HttpClient-class.html">HttpClient</a></span> </dt> <dd> An HTTP client for communicating with an HTTP server. </dd> <dt id="HttpClientBasicCredentials"> <span class="name "><a href="../dart-io/HttpClientBasicCredentials-class.html">HttpClientBasicCredentials</a></span> </dt> <dd> Represents credentials for basic authentication. </dd> <dt id="HttpClientCredentials"> <span class="name "><a href="../dart-io/HttpClientCredentials-class.html">HttpClientCredentials</a></span> </dt> <dd> </dd> <dt id="HttpClientDigestCredentials"> <span class="name "><a href="../dart-io/HttpClientDigestCredentials-class.html">HttpClientDigestCredentials</a></span> </dt> <dd> Represents credentials for digest authentication. Digest authentication is only supported for servers using the MD5 algorithm and quality of protection (qop) of either "none" or "auth". </dd> <dt id="HttpClientRequest"> <span class="name "><a href="../dart-io/HttpClientRequest-class.html">HttpClientRequest</a></span> </dt> <dd> HTTP request for a client connection. </dd> <dt id="HttpClientResponse"> <span class="name "><a href="../dart-io/HttpClientResponse-class.html">HttpClientResponse</a></span> </dt> <dd> HTTP response for a client connection. </dd> <dt id="HttpConnectionInfo"> <span class="name "><a href="../dart-io/HttpConnectionInfo-class.html">HttpConnectionInfo</a></span> </dt> <dd> Information about an <a href="../dart-io/HttpRequest-class.html">HttpRequest</a>, <a href="../dart-io/HttpResponse-class.html">HttpResponse</a>, <a href="../dart-io/HttpClientRequest-class.html">HttpClientRequest</a>, or <a href="../dart-io/HttpClientResponse-class.html">HttpClientResponse</a> connection. </dd> <dt id="HttpConnectionsInfo"> <span class="name "><a href="../dart-io/HttpConnectionsInfo-class.html">HttpConnectionsInfo</a></span> </dt> <dd> Summary statistics about an <a href="../dart-io/HttpServer-class.html">HttpServer</a>s current socket connections. </dd> <dt id="HttpDate"> <span class="name "><a href="../dart-io/HttpDate-class.html">HttpDate</a></span> </dt> <dd> Utility functions for working with dates with HTTP specific date formats. </dd> <dt id="HttpHeaders"> <span class="name "><a href="../dart-io/HttpHeaders-class.html">HttpHeaders</a></span> </dt> <dd> Headers for HTTP requests and responses. </dd> <dt id="HttpOverrides"> <span class="name "><a href="../dart-io/HttpOverrides-class.html">HttpOverrides</a></span> </dt> <dd> This class facilitates overriding <a href="../dart-io/HttpClient-class.html">HttpClient</a> with a mock implementation. It should be extended by another class in client code with overrides that construct a mock implementation. The implementation in this base class defaults to the actual <a href="../dart-io/HttpClient-class.html">HttpClient</a> implementation. For example: </dd> <dt id="HttpRequest"> <span class="name "><a href="../dart-io/HttpRequest-class.html">HttpRequest</a></span> </dt> <dd> A server-side object that contains the content of and information about an HTTP request. </dd> <dt id="HttpResponse"> <span class="name "><a href="../dart-io/HttpResponse-class.html">HttpResponse</a></span> </dt> <dd> An HTTP response, which returns the headers and data from the server to the client in response to an HTTP request. </dd> <dt id="HttpServer"> <span class="name "><a href="../dart-io/HttpServer-class.html">HttpServer</a></span> </dt> <dd> A server that delivers content, such as web pages, using the HTTP protocol. </dd> <dt id="HttpSession"> <span class="name "><a href="../dart-io/HttpSession-class.html">HttpSession</a></span> </dt> <dd> The <a href="../dart-io/HttpRequest/session.html">HttpRequest.session</a> of an <a href="../dart-io/HttpRequest-class.html">HttpRequest</a>. </dd> <dt id="HttpStatus"> <span class="name "><a href="../dart-html/HttpStatus-class.html">HttpStatus</a></span> </dt> <dd> HTTP status codes. Exported in dart:io and dart:html. </dd> <dt id="InternetAddress"> <span class="name "><a href="../dart-io/InternetAddress-class.html">InternetAddress</a></span> </dt> <dd> An internet address or a Unix domain address. </dd> <dt id="InternetAddressType"> <span class="name "><a href="../dart-io/InternetAddressType-class.html">InternetAddressType</a></span> </dt> <dd> The type, or address family, of an <a href="../dart-io/InternetAddress-class.html">InternetAddress</a>. </dd> <dt id="IOOverrides"> <span class="name "><a href="../dart-io/IOOverrides-class.html">IOOverrides</a></span> </dt> <dd> Facilities for overriding various APIs of <code>dart:io</code> with mock implementations. </dd> <dt id="IOSink"> <span class="name "><a href="../dart-io/IOSink-class.html">IOSink</a></span> </dt> <dd> A combined byte and text output. </dd> <dt id="Link"> <span class="name "><a href="../dart-io/Link-class.html">Link</a></span> </dt> <dd> References to filesystem links. </dd> <dt id="NetworkInterface"> <span class="name "><a href="../dart-io/NetworkInterface-class.html">NetworkInterface</a></span> </dt> <dd> A <a href="../dart-io/NetworkInterface-class.html">NetworkInterface</a> represents an active network interface on the current system. It contains a list of <a href="../dart-io/InternetAddress-class.html">InternetAddress</a>es that are bound to the interface. </dd> <dt id="Pipe"> <span class="name "><a href="../dart-io/Pipe-class.html">Pipe</a></span> </dt> <dd> An anonymous pipe that can be used to send data in a single direction i.e. data written to <a href="../dart-io/Pipe/write.html">write</a> can be read using <a href="../dart-io/Pipe/read.html">read</a>. </dd> <dt id="Platform"> <span class="name "><a href="../dart-io/Platform-class.html">Platform</a></span> </dt> <dd> Information about the environment in which the current program is running. </dd> <dt id="Process"> <span class="name "><a href="../dart-io/Process-class.html">Process</a></span> </dt> <dd> The means to execute a program. </dd> <dt id="ProcessInfo"> <span class="name "><a href="../dart-io/ProcessInfo-class.html">ProcessInfo</a></span> </dt> <dd> Methods for retrieving information about the current process. </dd> <dt id="ProcessResult"> <span class="name "><a href="../dart-io/ProcessResult-class.html">ProcessResult</a></span> </dt> <dd> The result of running a non-interactive process started with <a href="../dart-io/Process/run.html">Process.run</a> or <a href="../dart-io/Process/runSync.html">Process.runSync</a>. </dd> <dt id="ProcessSignal"> <span class="name "><a href="../dart-io/ProcessSignal-class.html">ProcessSignal</a></span> </dt> <dd> On Posix systems, <a href="../dart-io/ProcessSignal-class.html">ProcessSignal</a> is used to send a specific signal to a child process, see <code>Process.kill</code>. </dd> <dt id="ProcessStartMode"> <span class="name "><a href="../dart-io/ProcessStartMode-class.html">ProcessStartMode</a></span> </dt> <dd> Modes for running a new process. </dd> <dt id="RandomAccessFile"> <span class="name "><a href="../dart-io/RandomAccessFile-class.html">RandomAccessFile</a></span> </dt> <dd> Random access to the data in a file. </dd> <dt id="RawDatagramSocket"> <span class="name "><a href="../dart-io/RawDatagramSocket-class.html">RawDatagramSocket</a></span> </dt> <dd> An unbuffered interface to a UDP socket. </dd> <dt id="RawSecureServerSocket"> <span class="name "><a href="../dart-io/RawSecureServerSocket-class.html">RawSecureServerSocket</a></span> </dt> <dd> A server socket providing a stream of low-level <a href="../dart-io/RawSecureSocket-class.html">RawSecureSocket</a>s. </dd> <dt id="RawSecureSocket"> <span class="name "><a href="../dart-io/RawSecureSocket-class.html">RawSecureSocket</a></span> </dt> <dd> <code>RawSecureSocket</code> provides a secure (SSL or TLS) network connection. </dd> <dt id="RawServerSocket"> <span class="name "><a href="../dart-io/RawServerSocket-class.html">RawServerSocket</a></span> </dt> <dd> A listening socket. </dd> <dt id="RawSocket"> <span class="name "><a href="../dart-io/RawSocket-class.html">RawSocket</a></span> </dt> <dd> A TCP connection. </dd> <dt id="RawSocketEvent"> <span class="name "><a href="../dart-io/RawSocketEvent-class.html">RawSocketEvent</a></span> </dt> <dd> Events for the <a href="../dart-io/RawDatagramSocket-class.html">RawDatagramSocket</a>, <a href="../dart-io/RawSecureSocket-class.html">RawSecureSocket</a>, and <a href="../dart-io/RawSocket-class.html">RawSocket</a>. </dd> <dt id="RawSocketOption"> <span class="name "><a href="../dart-io/RawSocketOption-class.html">RawSocketOption</a></span> </dt> <dd> The <a href="../dart-io/RawSocketOption-class.html">RawSocketOption</a> is used as a parameter to <a href="../dart-io/Socket/setRawOption.html">Socket.setRawOption</a> and <a href="../dart-io/RawSocket/setRawOption.html">RawSocket.setRawOption</a> to customize the behaviour of the underlying socket. </dd> <dt id="RawSynchronousSocket"> <span class="name "><a href="../dart-io/RawSynchronousSocket-class.html">RawSynchronousSocket</a></span> </dt> <dd> A low-level class for communicating synchronously over a TCP socket. </dd> <dt id="RawZLibFilter"> <span class="name "><a href="../dart-io/RawZLibFilter-class.html">RawZLibFilter</a></span> </dt> <dd> The <a href="../dart-io/RawZLibFilter-class.html">RawZLibFilter</a> class provides a low-level interface to zlib. </dd> <dt id="ReadPipe"> <span class="name "><a href="../dart-io/ReadPipe-class.html">ReadPipe</a></span> </dt> <dd> The "read" end of an <a href="../dart-io/Pipe-class.html">Pipe</a> created by <a href="../dart-io/Pipe/create.html">Pipe.create</a>. </dd> <dt id="RedirectInfo"> <span class="name "><a href="../dart-io/RedirectInfo-class.html">RedirectInfo</a></span> </dt> <dd> Redirect information. </dd> <dt id="ResourceHandle"> <span class="name "><a href="../dart-io/ResourceHandle-class.html">ResourceHandle</a></span> </dt> <dd> A wrapper around OS resource handle so it can be passed via Socket as part of <a href="../dart-io/SocketMessage-class.html">SocketMessage</a>. </dd> <dt id="SameSite"> <span class="name "><a href="../dart-io/SameSite-class.html">SameSite</a></span> </dt> <dd> Cookie cross-site availability configuration. </dd> <dt id="SecureServerSocket"> <span class="name "><a href="../dart-io/SecureServerSocket-class.html">SecureServerSocket</a></span> </dt> <dd> A server socket, providing a stream of high-level <a href="../dart-io/Socket-class.html">Socket</a>s. </dd> <dt id="SecureSocket"> <span class="name "><a href="../dart-io/SecureSocket-class.html">SecureSocket</a></span> </dt> <dd> A TCP socket using TLS and SSL. </dd> <dt id="SecurityContext"> <span class="name "><a href="../dart-io/SecurityContext-class.html">SecurityContext</a></span> </dt> <dd> The object containing the certificates to trust when making a secure client connection, and the certificate chain and private key to serve from a secure server. </dd> <dt id="ServerSocket"> <span class="name "><a href="../dart-io/ServerSocket-class.html">ServerSocket</a></span> </dt> <dd> A listening socket. </dd> <dt id="Socket"> <span class="name "><a href="../dart-io/Socket-class.html">Socket</a></span> </dt> <dd> A TCP connection between two sockets. </dd> <dt id="SocketControlMessage"> <span class="name "><a href="../dart-io/SocketControlMessage-class.html">SocketControlMessage</a></span> </dt> <dd> Control message part of the <a href="../dart-io/SocketMessage-class.html">SocketMessage</a> received by a call to <a href="../dart-io/RawSocket/readMessage.html">RawSocket.readMessage</a>. </dd> <dt id="SocketDirection"> <span class="name "><a href="../dart-io/SocketDirection-class.html">SocketDirection</a></span> </dt> <dd> The <a href="../dart-io/SocketDirection-class.html">SocketDirection</a> is used as a parameter to <a href="../dart-io/Socket/close.html">Socket.close</a> and <a href="../dart-io/RawSocket/close.html">RawSocket.close</a> to close a socket in the specified direction(s). </dd> <dt id="SocketMessage"> <span class="name "><a href="../dart-io/SocketMessage-class.html">SocketMessage</a></span> </dt> <dd> A socket message received by a <a href="../dart-io/RawDatagramSocket-class.html">RawDatagramSocket</a>. </dd> <dt id="SocketOption"> <span class="name "><a href="../dart-io/SocketOption-class.html">SocketOption</a></span> </dt> <dd> An option for a socket which is configured using <a href="../dart-io/Socket/setOption.html">Socket.setOption</a>. </dd> <dt id="Stdin"> <span class="name "><a href="../dart-io/Stdin-class.html">Stdin</a></span> </dt> <dd> The standard input stream of the process. </dd> <dt id="StdioType"> <span class="name "><a href="../dart-io/StdioType-class.html">StdioType</a></span> </dt> <dd> The type of object a standard IO stream can be attached to. </dd> <dt id="Stdout"> <span class="name "><a href="../dart-io/Stdout-class.html">Stdout</a></span> </dt> <dd> An <a href="../dart-io/IOSink-class.html">IOSink</a> connected to either the standard out or error of the process. </dd> <dt id="SystemEncoding"> <span class="name "><a href="../dart-io/SystemEncoding-class.html">SystemEncoding</a></span> </dt> <dd> The system encoding is the current code page on Windows and UTF-8 on Linux and Mac. </dd> <dt id="TlsProtocolVersion"> <span class="name "><a href="../dart-io/TlsProtocolVersion-class.html">TlsProtocolVersion</a></span> </dt> <dd> A Transport Layer Security (TLS) version. </dd> <dt id="WebSocket"> <span class="name "><a href="../dart-io/WebSocket-class.html">WebSocket</a></span> </dt> <dd> A two-way HTTP communication object for client or server applications. </dd> <dt id="WebSocketStatus"> <span class="name "><a href="../dart-io/WebSocketStatus-class.html">WebSocketStatus</a></span> </dt> <dd> WebSocket status codes used when closing a WebSocket connection. </dd> <dt id="WebSocketTransformer"> <span class="name "><a href="../dart-io/WebSocketTransformer-class.html">WebSocketTransformer</a></span> </dt> <dd> The <a href="../dart-io/WebSocketTransformer-class.html">WebSocketTransformer</a> provides the ability to upgrade a <a href="../dart-io/HttpRequest-class.html">HttpRequest</a> to a <a href="../dart-io/WebSocket-class.html">WebSocket</a> connection. It supports both upgrading a single <a href="../dart-io/HttpRequest-class.html">HttpRequest</a> and upgrading a stream of <a href="../dart-io/HttpRequest-class.html">HttpRequest</a>s. </dd> <dt id="WritePipe"> <span class="name "><a href="../dart-io/WritePipe-class.html">WritePipe</a></span> </dt> <dd> The "write" end of an <a href="../dart-io/Pipe-class.html">Pipe</a> created by <a href="../dart-io/Pipe/create.html">Pipe.create</a>. </dd> <dt id="X509Certificate"> <span class="name "><a href="../dart-io/X509Certificate-class.html">X509Certificate</a></span> </dt> <dd> X509Certificate represents an SSL certificate, with accessors to get the fields of the certificate. </dd> <dt id="ZLibCodec"> <span class="name "><a href="../dart-io/ZLibCodec-class.html">ZLibCodec</a></span> </dt> <dd> The <a href="../dart-io/ZLibCodec-class.html">ZLibCodec</a> encodes raw bytes to ZLib compressed bytes and decodes ZLib compressed bytes to raw bytes. </dd> <dt id="ZLibDecoder"> <span class="name "><a href="../dart-io/ZLibDecoder-class.html">ZLibDecoder</a></span> </dt> <dd> The <a href="../dart-io/ZLibDecoder-class.html">ZLibDecoder</a> is used by <a href="../dart-io/ZLibCodec-class.html">ZLibCodec</a> and <a href="../dart-io/GZipCodec-class.html">GZipCodec</a> to decompress data. </dd> <dt id="ZLibEncoder"> <span class="name "><a href="../dart-io/ZLibEncoder-class.html">ZLibEncoder</a></span> </dt> <dd> The <a href="../dart-io/ZLibEncoder-class.html">ZLibEncoder</a> encoder is used by <a href="../dart-io/ZLibCodec-class.html">ZLibCodec</a> and <a href="../dart-io/GZipCodec-class.html">GZipCodec</a> to compress data. </dd> <dt id="ZLibOption"> <span class="name "><a href="../dart-io/ZLibOption-class.html">ZLibOption</a></span> </dt> <dd> Exposes ZLib options for input parameters. </dd> </dl> </section> <section class="summary offset-anchor" id="enums"> <h2>Enums</h2> <dl> <dt id="HttpClientResponseCompressionState"> <span class="name "><a href="../dart-io/HttpClientResponseCompressionState.html">HttpClientResponseCompressionState</a></span> </dt> <dd> Enum that specifies the compression state of the byte stream of an <a href="../dart-io/HttpClientResponse-class.html">HttpClientResponse</a>. </dd> </dl> </section> <section class="summary offset-anchor" id="constants"> <h2>Constants</h2> <dl class="properties"> <dt id="gzip" class="constant"> <span class="name "><a href="../dart-io/gzip-constant.html">gzip</a></span> <span class="signature">→ const <a href="../dart-io/GZipCodec-class.html">GZipCodec</a></span> </dt> <dd> An instance of the default implementation of the <a href="../dart-io/GZipCodec-class.html">GZipCodec</a>. </dd> <dt id="systemEncoding" class="constant"> <span class="name "><a href="../dart-io/systemEncoding-constant.html">systemEncoding</a></span> <span class="signature">→ const <a href="../dart-io/SystemEncoding-class.html">SystemEncoding</a></span> </dt> <dd> The current system encoding. </dd> <dt id="zlib" class="constant"> <span class="name "><a href="../dart-io/zlib-constant.html">zlib</a></span> <span class="signature">→ const <a href="../dart-io/ZLibCodec-class.html">ZLibCodec</a></span> </dt> <dd> An instance of the default implementation of the <a href="../dart-io/ZLibCodec-class.html">ZLibCodec</a>. </dd> </dl> </section> <section class="summary offset-anchor" id="properties"> <h2>Properties</h2> <dl class="properties"> <dt id="exitCode" class="property"> <span class="name"><a href="../dart-io/exitCode.html">exitCode</a></span> <span class="signature">↔ <a href="../dart-core/int-class.html">int</a></span> </dt> <dd> Get the global exit code for the Dart VM. <div class="features"><span class="feature">getter/setter pair</span></div> </dd> <dt id="pid" class="property"> <span class="name"><a href="../dart-io/pid.html">pid</a></span> <span class="signature">→ <a href="../dart-core/int-class.html">int</a></span> </dt> <dd> Returns the PID of the current process. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="stderr" class="property"> <span class="name"><a href="../dart-io/stderr.html">stderr</a></span> <span class="signature">→ <a href="../dart-io/Stdout-class.html">Stdout</a></span> </dt> <dd> The standard output stream of errors written by this program. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="stdin" class="property"> <span class="name"><a href="../dart-io/stdin.html">stdin</a></span> <span class="signature">→ <a href="../dart-io/Stdin-class.html">Stdin</a></span> </dt> <dd> The standard input stream of data read by this program. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="stdout" class="property"> <span class="name"><a href="../dart-io/stdout.html">stdout</a></span> <span class="signature">→ <a href="../dart-io/Stdout-class.html">Stdout</a></span> </dt> <dd> The standard output stream of data written by this program. <div class="features"><span class="feature">no setter</span></div> </dd> </dl> </section> <section class="summary offset-anchor" id="functions"> <h2>Functions</h2> <dl class="callables"> <dt id="exit" class="callable"> <span class="name"><a href="../dart-io/exit.html">exit</a></span><span class="signature">(<wbr><span class="parameter" id="exit-param-code"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span> <span class="parameter-name">code</span></span>) <span class="returntype parameter">→ Never</span> </span> </dt> <dd> Exit the Dart VM process immediately with the given exit code. </dd> <dt id="sleep" class="callable"> <span class="name"><a href="../dart-io/sleep.html">sleep</a></span><span class="signature">(<wbr><span class="parameter" id="sleep-param-duration"><span class="type-annotation"><a href="../dart-core/Duration-class.html">Duration</a></span> <span class="parameter-name">duration</span></span>) <span class="returntype parameter">→ void</span> </span> </dt> <dd> Sleep for the duration specified in <code>duration</code>. </dd> <dt id="stdioType" class="callable"> <span class="name"><a href="../dart-io/stdioType.html">stdioType</a></span><span class="signature">(<wbr><span class="parameter" id="stdioType-param-object"><span class="type-annotation">dynamic</span> <span class="parameter-name">object</span></span>) <span class="returntype parameter">→ <a href="../dart-io/StdioType-class.html">StdioType</a></span> </span> </dt> <dd> Whether a stream is attached to a file, pipe, terminal, or something else. </dd> </dl> </section> <section class="summary offset-anchor" id="typedefs"> <h2>Typedefs</h2> <dl> <dt id="BadCertificateCallback" class="callable"> <span class="name"><a href="../dart-io/BadCertificateCallback.html">BadCertificateCallback</a></span><span class="signature"> <span class="returntype parameter">= <a href="../dart-core/bool-class.html">bool</a> Function<span class="signature">(<span class="parameter" id="param-cr"><span class="type-annotation"><a href="../dart-io/X509Certificate-class.html">X509Certificate</a></span> <span class="parameter-name">cr</span>, </span><span class="parameter" id="param-host"><span class="type-annotation"><a href="../dart-core/String-class.html">String</a></span> <span class="parameter-name">host</span>, </span><span class="parameter" id="param-port"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span> <span class="parameter-name">port</span></span>)</span></span> </span> </dt> <dd> </dd> </dl> </section> <section class="summary offset-anchor" id="exceptions"> <h2>Exceptions / Errors</h2> <dl> <dt id="CertificateException"> <span class="name "><a href="../dart-io/CertificateException-class.html">CertificateException</a></span> </dt> <dd> An exception that happens in the handshake phase of establishing a secure network connection, when looking up or verifying a certificate. </dd> <dt id="FileSystemException"> <span class="name "><a href="../dart-io/FileSystemException-class.html">FileSystemException</a></span> </dt> <dd> Exception thrown when a file operation fails. </dd> <dt id="HandshakeException"> <span class="name "><a href="../dart-io/HandshakeException-class.html">HandshakeException</a></span> </dt> <dd> An exception that happens in the handshake phase of establishing a secure network connection. </dd> <dt id="HttpException"> <span class="name "><a href="../dart-io/HttpException-class.html">HttpException</a></span> </dt> <dd> </dd> <dt id="IOException"> <span class="name "><a href="../dart-io/IOException-class.html">IOException</a></span> </dt> <dd> Base class for all IO related exceptions. </dd> <dt id="OSError"> <span class="name "><a href="../dart-io/OSError-class.html">OSError</a></span> </dt> <dd> An <a href="../dart-core/Exception-class.html">Exception</a> holding information about an error from the operating system. </dd> <dt id="PathAccessException"> <span class="name "><a href="../dart-io/PathAccessException-class.html">PathAccessException</a></span> </dt> <dd> Exception thrown when a file operation fails because the necessary access rights are not available. </dd> <dt id="PathExistsException"> <span class="name "><a href="../dart-io/PathExistsException-class.html">PathExistsException</a></span> </dt> <dd> Exception thrown when a file operation fails because the target path already exists. </dd> <dt id="PathNotFoundException"> <span class="name "><a href="../dart-io/PathNotFoundException-class.html">PathNotFoundException</a></span> </dt> <dd> Exception thrown when a file operation fails because a file or directory does not exist. </dd> <dt id="ProcessException"> <span class="name "><a href="../dart-io/ProcessException-class.html">ProcessException</a></span> </dt> <dd> </dd> <dt id="RedirectException"> <span class="name "><a href="../dart-io/RedirectException-class.html">RedirectException</a></span> </dt> <dd> </dd> <dt id="SignalException"> <span class="name "><a href="../dart-io/SignalException-class.html">SignalException</a></span> </dt> <dd> </dd> <dt id="SocketException"> <span class="name "><a href="../dart-io/SocketException-class.html">SocketException</a></span> </dt> <dd> Exception thrown when a socket operation fails. </dd> <dt id="StdinException"> <span class="name "><a href="../dart-io/StdinException-class.html">StdinException</a></span> </dt> <dd> Exception thrown by some operations of <a href="../dart-io/Stdin-class.html">Stdin</a> </dd> <dt id="StdoutException"> <span class="name "><a href="../dart-io/StdoutException-class.html">StdoutException</a></span> </dt> <dd> Exception thrown by some operations of <a href="../dart-io/Stdout-class.html">Stdout</a> </dd> <dt id="TlsException"> <span class="name "><a href="../dart-io/TlsException-class.html">TlsException</a></span> </dt> <dd> A secure networking exception caused by a failure in the TLS/SSL protocol. </dd> <dt id="WebSocketException"> <span class="name "><a href="../dart-io/WebSocketException-class.html">WebSocketException</a></span> </dt> <dd> </dd> </dl> </section> </div> <!-- /.main-content --> <div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left"> <!-- The search input and breadcrumbs below are only responsively visible at low resolutions. --> <header id="header-search-sidebar" class="hidden-l"> <form class="search-sidebar" role="search"> <input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search..."> </form> </header> <ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav"> <li><a href="../index.html">Dart</a></li> <li class="self-crumb">dart:io</li> </ol> <h5><span class="package-name">Dart</span> <span class="package-kind">SDK</span></h5> <ol> <li class="section-title">Libraries</li> <li class="section-subtitle">Core</li> <li class="section-subitem"><a href="../dart-async">dart:async</a></li> <li class="section-subitem"><a href="../dart-collection">dart:collection</a></li> <li class="section-subitem"><a href="../dart-convert">dart:convert</a></li> <li class="section-subitem"><a href="../dart-core">dart:core</a></li> <li class="section-subitem"><a href="../dart-developer">dart:developer</a></li> <li class="section-subitem"><a href="../dart-math">dart:math</a></li> <li class="section-subitem"><a href="../dart-typed_data">dart:typed_data</a></li> <li class="section-subtitle">VM</li> <li class="section-subitem"><a href="../dart-ffi">dart:ffi</a></li> <li class="section-subitem"><a href="../dart-io">dart:io</a></li> <li class="section-subitem"><a href="../dart-isolate">dart:isolate</a></li> <li class="section-subitem"><a href="../dart-mirrors">dart:mirrors</a></li> <li class="section-subtitle">Web</li> <li class="section-subitem"> <a href="https://pub.dev/documentation/web/latest/" target="_blank"> package:web <span class="material-symbols-outlined">open_in_new</span> </a> </li> <li class="section-subitem"><a href="../dart-js_interop">dart:js_interop</a></li> <li class="section-subitem"><a href="../dart-js_interop_unsafe">dart:js_interop_unsafe</a></li> <li class="section-subtitle">Web (Legacy)</li> <li class="section-subitem"><a class="deprecated" href="../dart-html">dart:html</a></li> <li class="section-subitem"><a class="deprecated" href="../dart-indexed_db">dart:indexed_db</a></li> <li class="section-subitem"><a class="deprecated" href="../dart-js">dart:js</a></li> <li class="section-subitem"><a class="deprecated" href="../dart-js_util">dart:js_util</a></li> <li class="section-subitem"><a class="deprecated" href="../dart-svg">dart:svg</a></li> <li class="section-subitem"><a class="deprecated" href="../dart-web_audio">dart:web_audio</a></li> <li class="section-subitem"><a class="deprecated" href="../dart-web_gl">dart:web_gl</a></li> </ol> </div> <div id="dartdoc-sidebar-right" class="sidebar sidebar-offcanvas-right"> <h5>dart:io library</h5> </div><!--/sidebar-offcanvas-right--> </main> <footer> <span class="no-break"> Dart 3.7.2 </span> <span class="glue-footer"> <span class="no-break"> | <a href="https://dart.dev/terms" title="Terms of use">Terms</a> </span> <span class="no-break"> | <a href="https://policies.google.com/privacy" target="_blank" rel="noopener" title="Privacy policy" class="no-automatic-external">Privacy</a> </span> <span class="no-break"> | <a href="https://dart.dev/security" title="Security philosophy and practices">Security</a> </span> <div class="copyright" style="font-size: 0.9em; color: darkgrey; margin-top: 0.5em;"> Except as otherwise noted, this site is licensed under a <a style="color: darkgrey;" href="https://creativecommons.org/licenses/by/4.0/"> Creative Commons Attribution 4.0 International License</a> and code samples are licensed under the <a style="color: darkgrey;" href="https://opensource.org/licenses/BSD-3-Clause" class="no-automatic-external"> 3-Clause BSD License</a> </div> </span> </footer> <script src="../static-assets/highlight.pack.js?v1"></script> <script src="../static-assets/docs.dart.js"></script> <button aria-hidden="true" class="glue-footer__link glue-cookie-notification-bar-control"> Cookies management controls </button> <script src="https://www.gstatic.com/glue/cookienotificationbar/cookienotificationbar.min.js" data-glue-cookie-notification-bar-category="2B"> </script> </body> </html>