如何更快读取BufferedReader

我想优化这个代码: InputStream is = rp.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String text = ""; String aux = ""; while ((aux = reader.readLine()) != null) { text += aux; } 问题是,我不知道如何读取bufferedreader的内容,并以比上面更快的速度将其复制到string中。 我需要花尽可能less的时间。 谢谢

如何实现一个数组的3个堆栈?

有时,我遇到以下面试问题:如何实现一个数组的3个堆栈? 当然,任何静态分配都不是解决scheme。

有条件的键/ruby散列值

有没有一个很好的(一行)的ruby写一个哈希与一些条目只有在条件满足? 我想到了 {:a => 'a', :b => ('b' if condition)} 但是,这留下:b == nil如果条件不满足, :b == nil 。 我意识到这可以用两行左右的方式来完成,但是在一行中会更好(例如,当将散列传递给函数时)。 我还错过了另外一个ruby的惊人特征吗? ;)

在iOS应用程序中拨打电话

我有一些代码试图在应用程序中进行调用,但似乎没有工作: UIApplication *myApp = [UIApplication sharedApplication]; NSString *theCall = [NSString stringWithFormat:@"tel://%@",phone]; NSLog(@"making call with %@",theCall); [myApp openURL:[NSURL URLWithString:theCall]]; 有时,可变phone是诸如@"(102) 222-2222" 。 如何用这样的电话号码拨打电话? 我是否需要手动提取数字,摆脱所有额外的标点符号?

我怎样才能连接在Python中的string和数字?

我试图在Python中连接一个string和一个数字。 当我尝试这个时,它给了我一个错误: "abc" + 9 错误是: Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> "abc" + 9 TypeError: cannot concatenate 'str' and 'int' objects 为什么我无法做到这一点? 我怎样才能连接在Python中的string和数字? 请详细说明“通过”声明的用法…..

iOS – UIImageWriteToSavedPhotosAlbum

我想使用下面的void API来写一个捕获的图像到相册,但我不是很清楚关于2个参数 UIImageWriteToSavedPhotosAlbum ( UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo ); 从ADC的解释: completionTarget:可选; 在图像被写入“相机胶卷”相册后应调用其select器的对象。 completionSelector: completionTarget对象的方法select器。 此可选方法应符合以下签名: – (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo: (void *) contextInfo; completionTarget在这里有什么意义? 有人可以用一个例子来解释如何使用这个参数吗? 或任何资源,可以指导我通过它。

MongoDB正在运行,但无法使用shell进行连接

CentOS 5.x Linux与MongoDB 2.0.1(尝试主要和传统静态) MongoDB正在运行: root 31664 1.5 1.4 81848 11148 ? Sl 18:40 0:00 ./mongod -f mongo.conf -vvvvv –fork 使用简单的shell连接到服务器失败: [root@xxxx bin]# ./mongo MongoDB shell version: 2.0.1 connecting to: test Mon Oct 31 18:41:32 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84 exception: connect failed 端口28017上的Web界面加载正常,就像从远程Linux主机使用MongoDB shell一样。 也可以telnet到localhost:27017,这意味着没有端口被阻塞。 在这台机器上也没有运行SELinux。 我也试过显式指定localhost:2017/db无济于事。 $ ./mongo remote-ip:27017 MongoDB shell […]

从PowerShell中的列中select不同的项目

如果我在PowerShell中发出以下命令,则会返回很多行。 PS C:\Users\benh> get-command CommandType Name ModuleName Definition ———– —- ———- ———- Cmdlet Get-Variable Microsoft.PowerShell.Utility Get-Variable… Cmdlet Get-WebAppDomain WebAdministration Get-WebAppDomain… Cmdlet Get-WebApplication WebAdministration Get-WebApplication… Cmdlet Get-WebAppPoolState WebAdministration Get-WebAppPoolState… … Cmdlet Get-WinEvent Microsoft.PowerShell.Diagnostics Get-WinEvent… Cmdlet Get-WmiObject Microsoft.PowerShell.Management Get-WmiObject… Cmdlet Get-WSManCredSSP Microsoft.WSMan.Management Get-WSManCredSSP… Cmdlet Get-WSManInstance Microsoft.WSMan.Management Get-WSManInstance… Cmdlet Group-Object Microsoft.PowerShell.Utility Group-Object… Cmdlet Import-Alias Microsoft.PowerShell.Utility Import-Alias… Cmdlet Import-Clixml […]

如何解决警告:发送'ViewController * const __strong'参数的不兼容types'id <AVAudioPlayerDelegate>?

下面的代码给Sending 'ViewController *const __strong' to parameter of incompatible type 'id<AVAudioPlayerDelegate>' (它是下面的代码中的第三行)的Sending 'ViewController *const __strong' to parameter of incompatible type 'id<AVAudioPlayerDelegate>'警告: NSURL *sound0URL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"0" ofType:@"aiff"]]; audioPlayer0 = [[AVAudioPlayer alloc] initWithContentsOfURL:sound0URL error:nil]; [audioPlayer0 setDelegate: self]; // <— this line causes the warning [audioPlayer0 prepareToPlay]; audioPlayer0.currentTime = 0; [audioPlayer0 play]; 如何解决? 我在ViewController的viewDidLoad的实例方法中有这样的代码。 还有一个类似的问题,那就是一个类方法: 从Class中分配'id […]

为什么要在Java中声明一个不可变的类final?

我读到,要在Java中创build一个不可变的类 ,我们应该执行以下操作, 不要提供任何setter 将所有字段标记为私有 使课程最终 为什么需要步骤3? 我为什么要把课final标记?