User`s manual

5 Calling Java from MATLAB
5-64
BufferedReader object to variable br. A buffered reader provides for efficient
reading of characters, arrays, and lines.
isr = java.io.InputStreamReader(is)
br = java.io.BufferedReader(isr)
4. Read and Display Lines of Text
The final statement reads and displays the first 10 lines of text from the site.
Within a MATLAB
for statement that iterates 10 times, the BufferedReader
method
readLine reads a line of text (terminated by a return and/or line feed
character) from the site. To display the output in MATLAB, assign it to
variable
s, without terminating the statement with a semicolon.
for k = 1:10
s = readLine(br)
end
Running the Example
When you run this example, you see output similar to the following.
url =
http://www.ncsa.uiuc.edu/demoweb/url-primer.html
is =
java.io.BufferedInputStream@62d
isr =
java.io.InputStreamReader@67d
br =
java.io.BufferedReader@644
s =
<TITLE>A Beginner's Guide to URLs</TITLE>
s =
<H1>A Beginner's Guide to URLs</H1>
s =
''
s =
What is a URL? A URL is a <b>Uniform Resource Locator</b>. Think
s =
of it as a networked extension of the standard <i>filename</i>