我想知道什么是异常实例情况:
try {
// some risky actions
} catch (Exception e) {
System.out.println("Get instance name there");
}
Run Code Online (Sandbox Code Playgroud)
怎么做到这一点?
我遇到Safari的问题我无法解决:
<?php
header("Location: ftp://username:password@somedomain.org/somefile.zip");
?>
Run Code Online (Sandbox Code Playgroud)
此代码段适用于所有浏览器(Fx,Chrome,IE7-9),但不适用于最新的Safari,后者告诉我,我无权查看该页面(即重定向到正确的页面[ somedomain.org]使用正确的协议,但不处理身份验证数据).
有趣的是,当我将它直接复制到地址栏或者在<a>-tag中点击它时,它可以工作.这是一个Safari bug,还是我在这里遗漏了一些其他浏览器忽略的东西?如果它是一个Safari bug,是否有某种解决方法?
我正在尝试编写一个函数,它将以递归方式查找整数列表中的最大元素.我知道如何在Java中执行此操作,但无法理解如何在Scala中执行此操作.
这是我到目前为止,但没有递归:
def max(xs: List[Int]): Int = {
if (xs.isEmpty) throw new java.util.NoSuchElementException();
else xs.max;
}
Run Code Online (Sandbox Code Playgroud)
我们如何使用Scala语义递归地找到它.
我正在运行一个虚拟专用服务器,每天午夜,所有文件都由VPS提供商自动备份.
所以我需要将Solr索引导出到一个文件,这样如果有一天出现问题,我将能够轻松地将它导回到Solr.
我怎样才能做到这一点?
问题标题有点模糊,但我真的不知道这是什么东西.

我正在尝试创建其中一个黄色信息弹出窗口的东西.任何人都可以告诉我他们被称为什么以及如何创建它们?
我需要在Lua中生成随机浮点数.它必须> 1,因此math.random()不是解决方案.
我怎样才能做到这一点?
我正在使用Compass + Sass来管理/合并我的.css文件.所以我有以下文件夹结构:
Root
--Module
----css
----sass
--Module
----css
----sass
--Module
----css
----sass
Run Code Online (Sandbox Code Playgroud)
在这里我想要实现的目标:在开发阶段,我想将罗盘指向我的根文件夹,它应该监视位于sass目录(每个Module)中的文件的任何变化.一旦.sass文件中的一个更改 - .css应生成相应的文件(对于更改的模块.sass属于)并放入css相同的文件夹中Module.
可能吗?
我的猜测我应该config.rb用于此目的,但我不确定如何正确地做到这一点.有人能指出我的解决方案,或只是描述如何做到这一点的一般想法?
编辑:我在Windows环境中,所以无法使用Linux命令(我可以安装Cygwin,但我宁愿避免使用它)
谢谢
我正在尝试从控制台读取一个字符(在while循环中).但它不止一次地读过.
输入:
a
Run Code Online (Sandbox Code Playgroud)
输出:
char : a char : char : '
Run Code Online (Sandbox Code Playgroud)
码:
while(..)
{
char in;
scanf("%c",&in);
}
Run Code Online (Sandbox Code Playgroud)
我怎么才能读'a'?
嗨我有问题为我的Button设置多行,这是声明的:
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
button.titleLabel.numberOfLines = 0;
button.titleLabel.shadowOffset = CGSizeMake (1.0, 0.0);
[button addTarget:self
action:@selector(myButtonClick)
forControlEvents:UIControlEventTouchDown];
button.frame = CGRectMake(0.0, 100.0, 317.0, 100.0);
[button setTitle:string forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.text = @"ahoj";
NSMutableString *ObratString = [[NSMutableString alloc] initWithString:button.titleLabel.text];
[ObratString appendString:@"\n"];
[ObratString appendString:@"caw"];
[ObratString appendString:@"\n"];
[ObratString appendString:@"helllo"];
button.titleLabel.text = ObratString;
[ObratString release];
[self.view addSubview:button];
Run Code Online (Sandbox Code Playgroud)
但最后我才看到第一行.有没有办法使它工作?
嘿.今天我编写了一个小的基准脚本来比较复制变量的性能与创建对它们的引用.我期待,例如,创建对大型数组的引用将比复制整个数组慢得多.这是我的基准代码:
<?php
$array = array();
for($i=0; $i<100000; $i++) {
$array[] = mt_rand();
}
function recursiveCopy($array, $count) {
if($count === 1000)
return;
$foo = $array;
recursiveCopy($array, $count+1);
}
function recursiveReference($array, $count) {
if($count === 1000)
return;
$foo = &$array;
recursiveReference($array, $count+1);
}
$time = microtime(1);
recursiveCopy($array, 0);
$copyTime = (microtime(1) - $time);
echo "Took " . $copyTime . "s \n";
$time = microtime(1);
recursiveReference($array, 0);
$referenceTime = (microtime(1) - $time);
echo "Took " . $referenceTime . "s \n";
echo "Reference / …Run Code Online (Sandbox Code Playgroud)