InputStream inputStream = null;
        FileOutputStream fileOutputStream = null;
        byte[] buf = new byte[100];
        try {
            inputStream = new URL("http://xxx.xxx.xxx.xx/target.dat").openStream();
            String file_name = "result.dat";
            fileOutputStream = openFileOutput(file_name, MODE_WORLD_READABLE);
            int cnt = 0;
            while((cnt = inputStream.read(buf )) != -1) {
                fileOutputStream.write(buf , 0, cnt);
                fileOutputStream.flush();
            }
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        } finally {
            try {
                if(inputStream != null) inputStream.close();
                if(fileOutputStream != null) fileOutputStream.close();
            } catch(IOException ie) {}
        }

+ Recent posts