小编Bat*_*rai的帖子

将当前日期转换为整数

我想将当前日期转换为整数形式.默认情况下,它返回long.当我尝试将long转换为整数,然后我将整数值转换为日期意味着它显示1970年的日期.

 int i = (int) new Date().getTime();
 System.out.println("Integer : " + i);
 System.out.println("Long : "+ new Date().getTime());
 System.out.println("Long date : " + new Date(new Date().getTime()));
 System.out.println("Int Date : " + new Date(i));
Run Code Online (Sandbox Code Playgroud)

输出将成为

Integer : 1292838124
Long : 1345617601771
Long date : Wed Aug 22 12:10:01 IST 2012
Int Date : Fri Jan 16 04:37:18 IST 1970
Run Code Online (Sandbox Code Playgroud)

任何人请帮助我,如何将当前日期转换为整数(10位数字)

java date

28
推荐指数
4
解决办法
18万
查看次数

解密加密文件内容?

我在使用RSA公钥解密解密文件时遇到问题.我的过程是接收xml文件,加密内容,并将其写回同一文件.另一个功能是解密内容.我的源代码是:

public void decryptFile(String fileName,PrivateKey privateKey) throws Exception {
    Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
    cipher.init(Cipher.DECRYPT_MODE, privateKey);
    FileInputStream fis = new FileInputStream(fileName);
    File file=new File("decryptedfile.xml");
    if(file.exists()) {
        file.delete();
    }
            FileOutputStream fos = new FileOutputStream("decryptedfile.xml");
    CipherInputStream cis = new CipherInputStream(fis, cipher);
    int i;
    byte[] block = new byte[32];
    //System.out.println("Read : "+cis.read(block));
    while ((i = cis.read(block)) != -1) {
        System.out.println(String.valueOf(i));
        fos.write(block, 0, i);
    }
    fos.close();
}
Run Code Online (Sandbox Code Playgroud)

我只是将加密文件的名称和相应的私钥值传入函数.但是cis.read(block)第一次尝试时返回-1.任何人都可以建议我如何解密加密文件?

java encryption cryptography public-key-encryption

6
推荐指数
1
解决办法
1568
查看次数

在 Gitlab 中创建一个新分支

我想在 gitlab 中创建一个新的工作分支。我想成为那个分支的管理员。请有人帮助我学习如何在 Gitlab 中创建我自己的分支并将我的项目保留在该工作分支上...

git gitlab

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

golang - codecoverage总是显示覆盖率:0.0%的语句

我创建了一个示例go项目并为其创建了一个单元测试用例(在Linux环境中,go1.3版本)

当我运行go test输出时

通过
ok supported_db 0.201s

我尝试使用go test -cover它显示的命令为整个应用程序执行代码覆盖

去工具:没有这样的工具"覆盖"; 安装:
go get code.google.com/p/go.tools/cmd/cover

此外,我通过运行go test -cover CouchDB_test.go它显示的命令运行特定的测试用例时检查了覆盖率

ok命令行参数0.158s覆盖率:0.0%的语句

请帮我在golang中运行代码覆盖率.

code-coverage go

5
推荐指数
2
解决办法
3387
查看次数

在java中获取文件扩展名

我有一个问题是获得给定文件名的扩展名.我收到1个文件URL.
可能就像

/var/www.dir/file.tar.gz OR /var/www.dir/file.exe
Run Code Online (Sandbox Code Playgroud)

现在我需要从给定的URL中拆分文件扩展名(如.tar.gz OR .exe).URL由用户动态给出.任何人请帮帮我,如何解决这个问题

java file

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

启动Rails服务器时ExecJS :: RuntimeUnavailable错误

我创建了一个新的Rails应用程序.当我尝试启动服务器时,出现以下错误:

[bathakarai@Project1-CO samp]$ rails server
/home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /usr in PATH, mode 040777
/home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.4/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /usr in PATH, mode 040777
/home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `<top (required)>'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
    from /home/bathakarai/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails execjs

4
推荐指数
1
解决办法
6817
查看次数

安装mysql gem时出错

我正在使用linux机器.我成功安装了ruby并使用sqlite数据库创建了一个简单的应用程序.它也很好用.现在我尝试使用mysql创建一个应用程序,当我安装mysql gem时,它显示以下错误.

[bathakarai@Project1-CO Rails]$ gem install mysql
/home/bathakarai/.rvm/rubies/ruby-1.9.2-p320/bin/gem:4: warning: Insecure world writable dir /home/bathakarai in PATH, mode 040777
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

        /home/bathakarai/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
extconf.rb:12: warning: Insecure world writable dir /home/bathakarai in PATH, mode 040777
checking for mysql_ssl_set()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You …
Run Code Online (Sandbox Code Playgroud)

linux ruby-on-rails

3
推荐指数
2
解决办法
4865
查看次数

ERROR 1025(HY000):重命名时出错..(错误号:-1)

我在CentOS 5.7(64位)中使用Oracle MySQL 5.0.88.当我试图创建表的索引意味着它显示

mysql> CREATE INDEX activity_type_idON activity_log (activity_type_id); ERROR 1025(HY000):将'./sample_production/activity_log'重命名为'./sample_production/#sql2-665c-7'时出错(错误号:-1)

这是一些难以搜索的错误号码.请帮我解释为什么会发生此错误.

mysql database innodb mysql-5.0

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