问候人们.
我有这个奇怪的问题.在我正在进行的项目中,我需要将文件上传到FTP站点.我之前已经编写了许多程序,并且它们工作得很好.但这个特殊的网站给我带来了麻烦.当我尝试从程序上传文件时,我将其具体化:
java.net.UnknownHostException:ftp://site.com
但是,当我尝试从浏览器(Chrome,IE)或Windows资源管理器中连接到同一网站时,我能够找到该网站并登录就好了.我累了张贴照片,但由于我是新手,我被禁止这样做.
所以我现在很难过.如果我无法从Windows连接,那么我可以认为这是一个FTP服务器问题.这只发生在Java程序中.而且我也知道我的代码可以像以前在很多场合使用过一样.这是我使用的代码:
public void uploadFile(String fileName) throws Exception {
FileTransferClient ftpClient = null;
try {
ftpClient = new FileTransferClient();
ftpClient.setRemoteHost(gv.ftpHost);
ftpClient.setRemotePort(21);
ftpClient.setUserName(gv.ftpUserName);
ftpClient.setPassword(gv.ftpPassword);
ftpClient.getAdvancedFTPSettings().setConnectMode(FTPConnectMode.PASV);
ftpClient.connect();
ftpClient.uploadFile(gv.irp + fileName, fileName, WriteMode.OVERWRITE);
}
catch (Exception e) {
throw new Exception("Error occured in uploadFile()\n" + e);
}
finally {
if (ftpClient != null) {
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
ftpClient = null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用edtFTPj库.我的环境是从Windows 7 64位计算机运行的Java 1.6(32位)上的Eclipse Helios(32位).
任何有关解决此问题的见解将不胜感激.谢谢你的时间.
我想在JavaScript中按下链接时增加数组中的值
我使用以下代码
<script type="text/javascript">
var i=0;
var numbers = new Array();
function go(val){
numbers[i]=val;
i++;
alert(numbers[i]);
}
</script>
Run Code Online (Sandbox Code Playgroud)
像这样称为函数
<a href='javascript:go(1)' </a>
Run Code Online (Sandbox Code Playgroud)
但总是警报提示我'未定义'
我有一个不能被直接访问,在传统的RESTful方式的控制,而只能通过特定的URL.
通常我已经习惯了使用GET和POST在我的控制器的规格调用控制器动作.有没有办法通过访问特定网址来运用我的控制器?
编辑:
这是我的路线:
Larzworld::Application.routes.draw do
match '/auth/:provider/callback' => 'authentications#create'
devise_for :users, :controllers => {:registrations => "registrations"}
root :to => 'pages#home'
end
Run Code Online (Sandbox Code Playgroud)
这是我的规格:
require 'spec_helper'
describe AuthenticationsController do
before(:each) do
request.env["omniauth.auth"] = {"provider" => "twitter", "uid" => "12345678"}
end
describe 'POST create' do
it "should find the Authentication using the uid and provider from omniauth" do
Authentication.should_receive(:find_by_provider_and_uid)
post 'auth/twitter/callback'
end
end
end
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误:
Failures:
1) AuthenticationsController POST create should find the Authentication using the uid and provider from omniauth
Failure/Error: …Run Code Online (Sandbox Code Playgroud) 班级定义:
template<class K, class V,
unsigned hashFunc(const K&),
int compFunc(const K&,const K&)=&_compFunc<K> > class X {};
Run Code Online (Sandbox Code Playgroud)
我想在类代码块之外定义一个类方法.像这样:
template<class K, class V,
unsigned hashFunc(const K&),
int compFunc(const K&,const K&)=&_compFunc<K> >
X<K, V, hashFunc, compFunc>::X() { }
Run Code Online (Sandbox Code Playgroud)
g ++ v.4.4.3返回
error:包含'X :: X()'的类的模板参数的默认参数
为什么编译器会抱怨,我怎么能让它工作?
它们对数据库管理员以外的任何内容都有用吗?如果我理解正确,它只是可以直接保存到MySQL中的查询,因此任何Web开发团队都无法使用它们.
使用Apple和ImageMagick的PhotoScroller示例,我设法构建了我的目录应用程序.
但我有一个渲染错误.平铺图像在它们之间用细线渲染.
我使用ImageMagick的简单脚本是这样的:
#!/bin/sh
file_list=`ls | grep JPG`
for i in 100 50 25; do
for file in $file_list; do
convert $file -scale ${i}%x -crop 256x256 -set filename:tile "%[fx:page.x/256]_%[fx:page.y/256]" +repage +adjoin "${file%.*}_${i}_%[filename:tile].${file#*.}"
done
done
Run Code Online (Sandbox Code Playgroud)
Apple的代码是一样的.奇怪的是,他们提供的图像已经平铺,就像一个魅力,在同一个运行时间,与我的图像并排:(
我的第一个猜测是,磁贴的大小与代码上的计算不匹配,但更改大小无法修复,无论是在我的脚本还是在代码中.我的图像通常比苹果提供的图像小,实际上只有一半.
有人有同样的问题吗?
我需要构建各种命令并将它们作为参数传递给另一个程序.
这些命令共享一些信息和格式,但参数的数量不同.
例如,对于CRUD操作,我可能会生成以下命令字符串:
"create""host_ip""database""user_id""profile""personal_data1""personal_data2""personal_datan"
"retrive""host_ip""database""user_id"
"update""host_ip""database""user_id""personal_data1""personal_data2""personal_datan"
"delete""host_ip""database""user_id"
Run Code Online (Sandbox Code Playgroud)
我相信有更聪明的方法可以做到这一点并通过在这个神奇的网站上分享它,我可能会做得更好.
我需要检测文件中的第一个字符是否为等号(=)并显示行号.我该怎么写这个if陈述?
$i=0;
while (<INPUT>) {
my($line) = $_;
chomp($line);
$findChar = substr $_, 0, 1;
if($findChar == "=")
$output = "$i\n";
print OUTPUT $output;
$i++;
}
Run Code Online (Sandbox Code Playgroud) 当前实现:等待直到parallelCount收集值,用于ThreadPool处理值,等待所有线程完成,重新收集另一组值等等...
码:
private static int parallelCount = 5;
private int taskIndex;
private object[] paramObjects;
// Each ThreadPool thread should access only one item of the array,
// release object when done, to be used by another thread
private object[] reusableObjects = new object[parallelCount];
private void MultiThreadedGenerate(object paramObject)
{
paramObjects[taskIndex] = paramObject;
taskIndex++;
if (taskIndex == parallelCount)
{
MultiThreadedGenerate();
// Reset
taskIndex = 0;
}
}
/*
* Called when 'paramObjects' array gets filled
*/
private void …Run Code Online (Sandbox Code Playgroud) 我有这个ActionListener在EDT中被调用.我的plot()函数计算量很大,很容易花费五秒钟.它使GUI按预期挂起.我添加了SwingUtilities.invokeLater代码,它仍然挂起.由于我正在为我的升沉计算产生一个单独的线程,GUI不应该响应吗?
final ActionListener applyListener = new ActionListener()
{
@CommitingFunction
public void actionPerformed(ActionEvent arg0)
{
/*Don't do plotting in the EDT :)*/
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
plot();
}
});
}
};
Run Code Online (Sandbox Code Playgroud) java ×3
.net-3.5 ×1
asynchronous ×1
blocking ×1
c# ×1
c++ ×1
catiledlayer ×1
command ×1
controller ×1
edtftpj ×1
exception ×1
ftp ×1
imagemagick ×1
iphone ×1
javascript ×1
mysql ×1
perl ×1
queue ×1
rspec ×1
sql-server ×1
swing ×1
templates ×1
threadpool ×1
tiles ×1
uiscrollview ×1
upload ×1