我运行这段代码:
public class User {
public static void main(String args[]) {
int array[] = new int[10];
int i = 1;
try {
System.out.println("try: " + i++);
System.out.println(array[10]);
System.out.println("try");
} catch (Exception e) {
System.out.println("catch: " + i++);
System.out.println(array[10]);
System.out.println("catch");
} finally {
System.out.println("finally: " + i++);
Object o = null;
o.hashCode();
System.out.println("finally");
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
try:1
catch:2
finally:3
在user.main的线程"main"java.lang.NullPointerException中的异常(User.java:17)
在块catch中 - ArrayIndexOutOfBoundsException,但是我们丢失了这个Exception,为什么呢?
对于C#和.NET的System.Net.Sockets.Socket.AcceptAsync方法,需要处理返回值"false"以便处理SocketAsyncEventArgs来自同步处理的连接的立即可用状态.微软提供了一些例子(在System.Net.Sockets.SocketAsyncEventArgs类页面),如果存在大量挂起连接,则会导致堆栈溢出,这可以在任何实现其处理模型的系统上利用.
解决此问题的其他想法是创建一个调用处理程序方法的循环,其条件是值Socket.AcceptAsync返回等于false,并且如果值指示操作则中断循环(以允许延迟处理)正在异步完成(真实).但是,此解决方案还会导致堆栈溢出漏洞,因为与SocketAsyncEventArgs传递的关联的回调Socket.AcceptAsync在方法结束时有一个调用Socket.AcceptAsync,该调用还有一个用于立即可用,同步接受的连接的循环.
正如您所看到的,这是一个非常可靠的问题,我还没有找到一个不涉及System.Threading.ThreadPool并创建大量其他方法和调度处理的好解决方案.据我所知,与之相关的异步套接字模型Socket.AcceptAsync需要的内容要多于MSDN上的示例中所示的内容.
有没有人有一个干净有效的解决方案来处理从Socket.AcceptAsync同步接受的立即挂起的连接,而无需创建单独的线程来处理连接而不使用递归?
我在Global.asax中定义了几条路线;
当我在页面上时,我需要弄清楚当前路由的路由名称是什么,因为路由名称驱动我的站点菜单.
如何才能做到这一点?
我在我的网站上的主应用程序下面创建了一个"测试"应用程序,它与主应用程序完全相同 - 我使用/ test app测试新的更改,然后再将它们投入生产.
将应用程序从.NET 3.5升级到.NET 4.0后,我的/ test应用程序拒绝运行,从IIS返回500.19错误.我的主要应用程序(以及与/ test相同级别的另一个子应用程序)运行得很好.
我发现了很多关于500.19错误的引用,它们通常归结为web.config中的某些行无效.
但是,在我的情况下,错误并没有指向任何特定的行 - 错误消息在下面复制,请注意"配置源"部分为空.
Error Summary
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x800700b7
Config Error
Config File \\?\c:\blahblahblah\test\web.config
Requested URL http://localhost:80/blahblahblah/test
Physical Path C:\blahblahblah\test
Logon Method Not yet determined
Logon User Not yet determined
Config Source
-1: …Run Code Online (Sandbox Code Playgroud) 我已经开始在php中创建一个语法高亮显示器(只是一个快速的),到目前为止我有一个代码框生成器(也就是它创建一个表格,其样式看起来不错,可以显示源代码和HTML代码).在用它编写代码的那一刻,我这样做:
$code = "def example_ruby_code(does_it_work)
" . "(insert tab here) @does_it_work = false
" . "end"
codebox($code, "title_here.rb")
Run Code Online (Sandbox Code Playgroud)
我的麻烦是我知道我不能在html中有标签,所以我使用了以下内容:
preg_replace("/\t/", "     ", $code)
Run Code Online (Sandbox Code Playgroud)
(这进入了代码框功能)但它似乎不起作用,输出只显示没有任何缩进.有任何想法吗?在此先感谢,ell.
我试图使用XSLT样式表来转换XHTML,但我甚至无法获得基本样式表来匹配任何内容.我确定我错过了一些简单的事情.
这是我的XHTML源文档(没什么大惊喜):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 25 March 2009), see www.w3.org" />
...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
实际内容并不重要,我将在下面演示.顺便说一句,我很确定该文档是通过创建文档而形成的tidy -asxml.
我更复杂的XPath表达式没有返回任何结果,所以作为一个完整性测试,我试图使用以下样式表非常简单地转换它:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<xsl:text>---[</xsl:text>
<xsl:for-each select="html">
<xsl:text>Found HTML element.</xsl:text>
</xsl:for-each>
<xsl:text>]---</xsl:text>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
转换是通过完成的xsltproc --nonet stylesheet.xsl input.html,输出是:"--- [] ---"(即,它没有找到子元素html).但是,如果我将该for-each部分更改为:
<xsl:for-each select="*">
<xsl:value-of select="name()"/>
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)
然后我得到"--- [html] ---".同样,如果我使用for-each select="*/*",我会像我期望的那样得到"--- [headbody] …
我想为我的iphone应用程序提供文件加密功能.对于基于桌面的应用程序,我使用下面的函数来加密相对较小的文件:
- (NSData *)aesEncrypt:(NSString *)key {
// 'key' should be 32 bytes for AES256, will be null-padded otherwise
char keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
// fetch key data
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
NSUInteger dataLength = [self length];
//See the doc: For block ciphers, the output size will always be less than or
//equal to the input size plus the size of one block.
//That's why we need to add the size …Run Code Online (Sandbox Code Playgroud) 尝试在我的应用程序中创建基于谷歌地图的自定义信息窗口.
下一个例子是我的开发基点之一:
http://gmaps-samples-v3.googlecode.com/svn/trunk/infowindow_custom/infowindow-custom.html
问题是,无论我使用这个或其他一些例子,在forefox的firebug我都会收到错误
google is not defined
InfoBox.prototype = new google.maps.OverlayView();
Run Code Online (Sandbox Code Playgroud)
你能帮我解决这个问题,如果没有自定义信息,我无法继续工作.....
我正在读关于优化teckniks的书.但是在示例中没有太多描述或建议.这是事情:
int agag(int a)
{
static int dfdfdf = 0;
static int prev_resilt = 0;
if (dfdfdf == a)
return prev_result;
dfdfdf = a;
a = SomeCalcs();
prev_result = a;
return a;
}
Run Code Online (Sandbox Code Playgroud)
关键是:如果参数与先前的计算相同,它将立即返回先前的结果,避免进行硬计算.问题是:这两个静态变量会在程序结束之前存在吗?据我了解,拥有很多这些是件坏事?
我知道这不是很多优化.但我只关心静态变量的影响..
非常感谢你的答案!
您是否可以将一个按钮作为子视图添加到uitableview单元格中并使其具有可单击性,而不是单元格本身.即:我不希望所选的视图出现.Obvs我可以不让细胞在任何地方透露,但我不希望当有人点击它时它看起来"被选中".
将用户交互设置为NO会使整个事情无法执行,包括按钮.
有任何想法吗?
谢谢.
汤姆
asp.net ×2
iphone ×2
asynchronous ×1
c ×1
c# ×1
cocoa ×1
encryption ×1
exception ×1
finally ×1
html ×1
infowindow ×1
java ×1
objective-c ×1
optimization ×1
php ×1
regex ×1
routing ×1
sockets ×1
static ×1
tabs ×1
try-catch ×1
uitableview ×1
url-routing ×1
webforms ×1
xslt ×1