⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getfile.m

📁 物流分析工具包。Facility location: Continuous minisum facility location, alternate location-allocation (ALA)
💻 M
字号:
function XFlg = getfile(baseurl,fnin,fnout)
%GETFILE Download file from Internet and save local copy.
% XFlg = getfile(baseurl,fnin,fnout)
% baseurl = base URL address
%         = 'http://www.ie.ncsu.edu/kay/matlog/', default
%    fnin = name of file to read from from web
%   fnout = name of file to write to local directory
%         = 'fnin', default
%    XFlg = 1, able to get file
%         = 0, not able

% Copyright (c) 1994-2006 by Michael G. Kay
% Matlog Version 9 13-Jan-2006 (http://www.ie.ncsu.edu/kay/matlog)

% Input Error Checking ****************************************************
error(nargchk(2,3,nargin))

if nargin < 3 || isempty(fnout), fnout = fnin; end
if isempty(baseurl), baseurl = 'http://www.ie.ncsu.edu/kay/matlog/'; end

if ~ischar(baseurl) || ~ischar(fnin) || ~ischar(fnout)
   error('Input arguments must be strings.')
end
baseurl = baseurl(:)';
fnin = fnin(:)'; fnout = fnout(:)';
% End (Input Error Checking) **********************************************

try
   url = java.net.URL([baseurl fnin]);
   br = java.io.DataInputStream(openStream(url));
catch
   if nargout > 0
      XFlg = 0;
      return
   else
      rethrow(lasterr)
   end
end

fid = fopen(fnout,'wb');

x = read(br);
while x > -1
   fwrite(fid,x);
   x = read(br);
end

close(br);
fclose(fid);

if nargout > 0, XFlg = 1; end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -