java打不开url类,download.file(current_file,destfile)出错:无法打开URL

我有一个功能,下载.bz2文件,扩展它们,并将数据写入磁盘 . 该函数在过去运行,但现在循环中的第二个文件出错:“download.file(current_file,destfile)中的错误...无法打开URL”我已经更改了所请求文件的顺序并且还进行了测试使用ftp客户端下载文件 . 似乎download.file()正在超时 . 当我手动下载文件时,存在显着的暂停 .

Here is my code:

# BuildMetFilesMain.R

# Author: John Orr

# This is the top-level R script to build the meteorological forcing files for

# the Clear Creek at Golden VIC model.

#

BuildMetFilesMain

# Downloads and/or builds the meteorological forcing files for the

# Clear Creek at Golden VIC model

if(getFiles == TRUE) {

# Read the Clear Creek soil.06719505latandlongonly file

# for lat and long for the desired .bz2 file from Livneh

# Research Group

file_with_path

conn

linn

# Construct the download path and download the forcing file by

# iterating across the lat and long file. For this project the lat is always

# length 8 and long is always length 10. .BZ2 files to download are located at

# ftp://gdo-dcp.ucllnl.org/pub/dcp/archive/OBS/livneh2014.1_16deg/ascii/daily/. Directories

# start with "latitude. and the filename is

# Meteorology_Livneh_NAmerExt_15Oct2014__.bz2.

for(i in 1:length(linn)){

#for(i in 1:1){get

current_lat_long

current_lat

current_long

# Build the filename for current_lat and current_long

current_file

current_lat, "/Meteorology_Livneh_NAmerExt_15Oct2014_", current_lat, "_",

current_long, ".bz2", sep = "")

# Build the filename for the tab delimited file

destfile

destfile

destfile

# Retrieve the file for the current_lat and current_long from the Internet

download.file(current_file, destfile)

# Write the data in tab delimited format in the "forcings" directory

data

write.table(data, file = destfile, quote = FALSE, sep = "\t", na = "NA", row.names = FALSE, col.names = FALSE)

}

}

}

RStudio控制台的输出:

> source('~/Documents/ClearCreek/BuildMetFilesMain.R')

> BuildMetFilesMain()

trying URL 'ftp://gdo-dcp.ucllnl.org/pub/dcp/archive/OBS/livneh2014.1_16deg/ascii/daily/latitude.39.59375/Meteorology_Livneh_NAmerExt_15Oct2014_39.59375_-105.65625.bz2'

Content type 'unknown' length 135942 bytes (132 KB)

==================================================

trying URL 'ftp://gdo-dcp.ucllnl.org/pub/dcp/archive/OBS/livneh2014.1_16deg/ascii/daily/latitude.39.59375/Meteorology_Livneh_NAmerExt_15Oct2014_39.59375_-105.59375.bz2'

Error in download.file(current_file, destfile) :

cannot open URL 'ftp://gdo-dcp.ucllnl.org/pub/dcp/archive/OBS/livneh2014.1_16deg/ascii/daily/latitude.39.59375/Meteorology_Livneh_NAmerExt_15Oct2014_39.59375_-105.59375.bz2'

In addition: Warning message:

In download.file(current_file, destfile) :

URL 'ftp://gdo-dcp.ucllnl.org/pub/dcp/archive/OBS/livneh2014.1_16deg/ascii/daily/latitude.39.59375/Meteorology_Livneh_NAmerExt_15Oct2014_39.59375_-105.59375.bz2': status was 'Failure when receiving data from the peer'

>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值