小编dj1*_*j18的帖子

如何声明和关闭InputSteam?

以下哪一项是关闭和声明inputStream的首选方法.

InputStream is = null; 
String md5;
try{
    is = new FileInputStream(FILE.getAbsoluteFile());
    md5 = UTILS.getMD5Info(is);
} finally{
    if(is != null) 
        is.close();
}
Run Code Online (Sandbox Code Playgroud)

要么

InputStream is = new FileInputStream(FILE.getAbsoluteFile()); 
String md5;
try{
    md5 = UTILS.getMD5Info(is);
} finally{
    is.close();
}
Run Code Online (Sandbox Code Playgroud)

我没有看到两者之间有太大差异,但第二种方式看起来更好,因为它有点短.如果我们不想捕获异常并且只是对收集inputStream的垃圾感兴趣,那么在try块中是否有任何初始化输入流的用法?

java exception-handling inputstream

4
推荐指数
2
解决办法
3885
查看次数

sql获取日期的具体时间

我想编写一个SQL查询来返回昨天晚上9点到当前时间的结果.据我所知,GETDATE()只会给我今天的结果,并GETDATE()-1会给我昨天的全部,我不想要的.

如何实现这一目标?

sql database sql-server time date

3
推荐指数
1
解决办法
7049
查看次数

ConfigurationManager未声明 - 有dll

快速背景:我有一个VB.NET应用程序,我之前使用ConfigurationSettings.AppSettings从app.config读取,并收到一条错误消息,将其更改为System.Configuration.ConfigurationManager.AppSettings(因为第一种方式现已过时) )

我这样做了,我甚至在顶部引用了System.Configuration.dll和Imports语句,但是我收到了"Name ConfigurationManager not declared"错误消息.有什么建议?

代码:这很简单 - 我只是检查某些东西是否存在,如果存在,我会从中读取:

If Not Exists(ConfigurationManager.AppSettings.Get(rep & "Email")) Then
        Return False
End If

message = ReadAllText(ConfigurationManager.AppSettings.Get(rep & "Email"))
Run Code Online (Sandbox Code Playgroud)

vb.net configurationmanager

3
推荐指数
1
解决办法
1万
查看次数

如何解决'.class'预期错误?

目前我有一个错误 - '.class'预计 - 在第40行.任何帮助都非常感谢.

    import java.io.*; // For File class and FileNotFoundException
import java.util.Scanner; //For the Scanner class
import javax.swing.JOptionPane; // For the JOptionPane class
/**
 * Write a description of class PartB here.
 * 
 * @Hubble, Kieran 
 * @Version 0.1
 */
public class PartB
{
    public static void main(String[] args) throws FileNotFoundException
    {
        File file; //for file input
        Scanner inputFile; //for file input
        String fileName; //to hold a file name
        String paragraph; //to extract the letter frequencies

        //get …
Run Code Online (Sandbox Code Playgroud)

java

0
推荐指数
1
解决办法
660
查看次数