MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Uživatelský manuál Strana 234

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 408
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 233
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>
Zobrazit stránku 233
1 2 ... 229 230 231 232 233 234 235 236 237 238 239 ... 407 408

Komentáře k této Příručce

Žádné komentáře