Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to convert the input stream into a file and then use File Reader.</p> <pre><code> URL url; try { url = new URL("ftp://" + USER_NAME + ":" + PASSWORD + "@" + SERVER + "/study/" + FILE_NAME + ";type=i"); URLConnection con = url.openConnection(); File tmpFile = new File("tmpFile.java"); OutputStream out = new FileOutputStream(f); InputStream inputStream = con.getInputStream(); byte buf[] = new byte[1024]; int len; while ((len = inputStream.read(buf)) &gt; 0) out.write(buf, 0, len); out.close(); inputStream.close(); } catch (IOException e) { } </code></pre> <p>The obove code creats a file object tmpFile from the input stream. You can use Filereader on this file object. </p> <pre><code> FileReader fileReader=new FileReader(tmpFile); int ch= fileReader.read(); while(ch != -1){ System.out.print((char)ch); ch = fileReader.read(); } fileReader.close(); </code></pre> <p>Notice that File Reader reads character by character.Thats why people prefer BufferedReader over it.</p> <p>In general, each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream. It is therefore advisable to wrap a BufferedReader around any Reader whose read() operations may be costly, such as FileReaders and InputStreamReaders. For example,</p> <pre><code>BufferedReader in = new BufferedReader(new FileReader("foo.in")); </code></pre> <p>will buffer the input from the specified file. Without buffering, each invocation of read() or readLine() could cause bytes to be read from the file, converted into characters, and then returned, which can be very inefficient.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload