可能重复:
java中的"using"关键字
我正在从C#转换到java,所以请耐心等待...
在C#中读取文件时,只需将其全部包装在一个大的"使用"块中,这样如果您有异常,该文件仍将被关闭.像这样(可能不准确,但你明白了):
using(FileStream fs = new FileStream("c:\\myfile.txt")) {
  // Any exceptions while reading the file here won't leave the file open
}
Run Code Online (Sandbox Code Playgroud)
java 5或6中是否有方便的等价物?我得到的印象是,最近java一直在"借用"来自c#的一些语法糖(例如foreach),所以如果有一个类似于使用这些天的java,我也不会感到惊讶.
或者我只需要使用try..finally块?我认为'使用'真是太好了......
基本上我想使用System.Security.Cryptography.AesManaged(或者更好的类,如果你认为有一个?)来获取一个字节数组并使用给定的对称密钥创建另一个加密的字节数组(我假设我需要一?).
我还需要改变这个程序的方法.
关键是我可以加密存储的密码.我假设有一种简单的方法可以做到这一点?
谢谢
I'm using NSLog to inspect a UITextView. I have the following logging statements in my code:
    NSLog(@"textView: %@",textView);
    NSLog(@"textView.frame: %@",textView.frame);
    NSLog(@"[textView frame]: %@",[textView frame]);
Run Code Online (Sandbox Code Playgroud)
And in the output to the console, i get the following:
2010-11-29 22:00:38.252 MenuMaker[57602:207] textView: <UITextView: 0x3b3afe0; frame = (0 0; 320 387); text = 'blah...'; clipsToBounds = YES; autoresize = RM+BM; layer = <CALayer: 0x3b3afa0>>
2010-11-29 22:00:38.254 MenuMaker[57602:207] textView.frame: (null)
2010-11-29 22:00:38.254 MenuMaker[57602:207] [textView frame]: (null)
Run Code Online (Sandbox Code Playgroud)
The first line of output, since it contains the …
我Encrypt=yes在SQL Server连接字符串中使用,因为我需要加密TCPIP流量,但在打开连接时出现错误:
A connection was successfully established with the server, but then an error
occurred during the pre-login handshake. (provider: SSL Provider, error: 0 -
The certificate's CN name does not match the passed value.)
Run Code Online (Sandbox Code Playgroud)
有任何建议如何解决这个问题?我假设我的服务器之间需要某种证书关系,但不知道从哪里开始.
我需要两个连接,一个连接到SQL 2000服务器,一个连接到2005服务器.
如果你在外面点击它,如何让你的uiactionsheet消失?这适用于iPhone.显然,ipad默认这样做(我可能错了).
我们试图决定是否值得在项目中使用实体框架4.为此,我认为一个好的开始就是将它与nhibernate进行比较,nhibernate已经成熟并且经过多年的使用证明了拥有人们对企业应用程序所需的所有功能,并且找出了nHibernate缺少哪些EF4缺少的功能出去.
首先,我的知识有限:
找到一些文章:
http://ayende.com/blog/archive/2010/01/05/nhibernate-vs.-entity-framework-4.0.aspx
我有一个函数(内部使用ASIHTTPRequest),它调用一个结果块:
[Http get:@"http://api.geonames.org/postalCodeLookupJSON"
   params:params cacheMins:0 complete:^(NSDictionary *response, BOOL success) {
       STAssertTrue(success, @"JSON retrieved OK");
       STFail(@"blah");
}];
Run Code Online (Sandbox Code Playgroud)
我想测试上面的内容,但似乎测试没有被调用.
如何确保测试等到块被调用?
-编辑-
当然我不建议在gui线程的主应用程序中执行此操作,在这种特殊情况下,它仅用于单元测试.
花了很多时间从应用程序中驱逐asp.net的大型(但可以理解的有用)视图状态,我认为值得分享它是如何完成的.
基本上,我希望这个问题对缩小/压缩/删除视图状态的所有解决方案开放.
在iphone app/ios中,如何制作覆盖导航栏和键盘的透明"加载"覆盖图?
我尝试了以下但它不包括导航栏和键盘:
UIView *overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
overlay.backgroundColor = [UIColor colorWithWhite:0 alpha:.5];
[self.view addSubview:overlay];
Run Code Online (Sandbox Code Playgroud)
谢谢
c# ×5
objective-c ×4
encryption ×2
ios ×2
iphone ×2
asp.net ×1
cocoa-touch ×1
cryptography ×1
exception ×1
file ×1
java ×1
lambda ×1
linq ×1
math ×1
nhibernate ×1
nslog ×1
public-key ×1
rsa ×1
secret-key ×1
sql ×1
sql-server ×1
ssl ×1
uitextview ×1
uiview ×1
unit-testing ×1
using ×1
viewstate ×1