The Java(tm) FAQ -- Input, Output, and Network
Copyright
Table of Contents
Chapters:
1
2
3
4
5
6
7
8
9
10
11
Outline
Q10.1
How do I read a line of input at a time?
ReadLineExample.html, ReadLine11Example.html
See also: Q10.3
Q10.2
How do I read input from the user (or send output) analogous to using
standard input and standard output in C or C++?
StandardInputOutputExample.html, StandardInputOutput11Example.html
See also: Q10.1, Q10.3, Q10.4, Q10.5
Q10.3
Why do I get garbage results when I use DataInputStream's
readInt or readFloat methods to read in a
number from an input string?
ReadIntExample.html
See also: Q10.1
Q10.4
Is there a standard way to read in int,
long, float, and double values
from a string representation?
ReadNumberExample.html, ReadNumber11Example.html
See also: Q4.19
Q10.5
When do I need to flush an output stream?
See also: Q10.2
Q10.6
Why do I see no output when I run a simple process, such as
r.exec("/usr/bin/ls")?
ProcessOutputExample.html, ProcessOutput11Example.html
See also: Q10.2
Q10.7
What's the difference between a URL instance and a
URLConnection instance?
Q10.8
How do I make a connection to a URL?
URLConnectionExample.html
See also: Q2.23, Q2.24, Q10.9
Q10.9
How do I read from a remote file if I have its URL?
ReadFromURLExample.html, ReadFromURLAppletExample.html
See also: Q10.1, Q10.2, Q10.6
Q10.10
Why do I get a null result when I use the
getHeader... methods in the URLConnection
class?
GetHeaderExample.html
Q10.11
What is URLConnection's getOutputStream
method intended to work with on the server side?
See also: Q10.12
Q10.12
How do I send data from my Java program to a CGI program?
PostExample.html
See also: Q10.8
Q10.13
Can I write (from my applet) to an external file on a URL?
See also: Q10.12, Q10.13
Q10.14
How can my Java stand-alone application fetch documents in the same
fashion as (partially simulating) a browser?
See also: Q10.9
Q10.15
Why do I get a security exception when I try to connect to an external
URL from an applet? (If I run equivalent code as an application, it
works fine.)
Q10.16
The API doesn't list any constructors for InetAddress --
how do I create an InetAddress instance?
InetAddressExample.html
See also: Q1.6, Q1.7, Q2.23
Q10.17
Is it possible to get the real local host IP?
LocalHostExample.html
See also: Q10.16
Q10.18
How can I create an InetAddress instance from an IP
address that has no DNS entry?
See also: Q10.16, Q10.20, Q10.27
Q10.19
How do I create and use sockets in Java?
SocketExample.html, Socket11Example.html
See also: Q10.3
Q10.20
How can I get a server socket and client socket going on a stand-alone
machine, not on a network?
SocketWithoutNetworkExample.html, SocketWithoutNetwork11Example.html
See also: Q10.19
Q10.21
Will raw sockets ever be introduced -- and if not, how can I create
ICMP messages so that I can do operations like `ping'?
Q10.22
How do I detect if an input stream belonging to a socket has been
terminated by the remote host?
See also: Q10.19
Q10.23
If the Socket class has no support for firewalls, how can
I get my Java program with sockets to work through different
firewalls?
See also: Q10.19
Q10.24
How do I create a nonblocking server socket in Java?
NonblockingServerExample.html, NonblockingServer11Example.html
See also: Q10.19
Q10.25
Is there a standard Java way to specify the address of the host doing
the listening when instantiating a ServerSocket?
See also: Q10.19, Q10.24
Q10.26
How do I send and/or receive datagram packets?
DatagramExample.html
See also: Q10.19
Q10.27
When will I be able to create a broadcast datagram packet?
BroadcastExample.html
See also: Q10.18, Q10.26