小编Jav*_*eek的帖子

如何使用与插入时相同的顺序获取Map中的键

我正在尝试在Map中放入一些键值,并尝试以与插入时相同的顺序检索它们.例如下面是我的代码

import java.util.*;
import java.util.Map.Entry;

public class HashMaptoArrayExample {

    public static void main(String args[])

    {
   Map<String,Integer> map=  new HashMap<String,Integer>();

   // put some values into map

   map.put("first",1);
   map.put("second",2);
   map.put("third",3);
   map.put("fourth",4);
   map.put("fifth",5);
   map.put("sixth",6);
   map.put("seventh",7);
   map.put("eighth",8);
   map.put("ninth",9);



    Iterator iterator= map.entrySet().iterator();
       while(iterator.hasNext())
       {
           Entry entry =(Entry)iterator.next();   
           System.out.println(" entries= "+entry.getKey().toString());
       }

    }
}
Run Code Online (Sandbox Code Playgroud)

我想检索如下的密钥

first second third fourth fifth sixth .....
Run Code Online (Sandbox Code Playgroud)

但它在我的输出中以一些随机顺序显示如下

OUTPUT

ninth eigth fifth first sixth seventh third fourth second
Run Code Online (Sandbox Code Playgroud)

java

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

如何在边框中放置文字

我试图在边框插入一些文字,但不知道该怎么做.

我怎样才能在边框中间放置一些文字.

下面是它应该看起来的屏幕截图

在此输入图像描述

html css

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

Java正则表达式不敏感不起作用

我正在尝试使用以下程序使用正则表达式删除字符串中的某些单词.它正确删除,但它只考虑区分大小写.如何使其不区分大小写.我保留(?1)了replaceAll方法,但它没有用.

package com.test.java;

public class RemoveWords {

    public static void main(String args[])
    {

        // assign some words to string

        String sample ="what Is the latest news today in Europe? is there any thing special or everything is common.";

            System.out.print(sample.replaceAll("( is | the |in | any )(?i)"," "));
    }
}
Run Code Online (Sandbox Code Playgroud)

OUTPUT:

what Is latest news today  Europe? there thing special or everything common.
Run Code Online (Sandbox Code Playgroud)

java regex

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

SSL不适用于Tomcat 8

我正在尝试为tomcat 8配置SSL(https),并且已完成以下步骤,但仍无法正常工作

1)使用创建密钥库文件

keytool -genkey -alias myservername -keyalg RSA
Run Code Online (Sandbox Code Playgroud)

2)生成CSR如下

keytool -certreq -alias myservername -file C:\tomcat_ssl\local_machine\test.csr -keystore C:\tomcat_ssl\local_machine\test.keystore
Run Code Online (Sandbox Code Playgroud)

3)然后我们生成证书,然后导入链证书和证书,如下所示

keytool -import -alias root -keystore C:\tomcat_ssl\local_machine\test.keystore -trustcacerts -file C:\tomcat_ssl\local_machine\srv_chain.cer

keytool -import -alias myservername -keystore C:\tomcat_ssl\local_machine\test.keystore -file C:\tomcat_ssl\local_machine\srv_main.cer
Run Code Online (Sandbox Code Playgroud)

4)最后在tomcat server.xml中进行了如下更改

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="C:\tomcat_ssl\local_machine\test.keystore" keystorePass="123" keystoreAlias="myservername"/>
Run Code Online (Sandbox Code Playgroud)

重新启动tomcat,它不工作并显示在屏幕下方

访问tomcat https时出错

在Tomcat的日志它没有显示任何错误,也是我试过其他选项,如保持cipher在连接标签Enabled TLS 1,2,3,更改HTTPS端口等无济于事.

此外,我测试了https端口443,它显示为我在netstat时的监听.知道为什么这不起作用

在tomcat中启用ssl调试后添加了日志

http-nio-443-exec-5, fatal error: 10: General SSLEngine problem
javax.net.ssl.SSLHandshakeException: SSLv2Hello is disabled
http-nio-443-exec-5, SEND TLSv1.2 ALERT:  fatal, description = unexpected_message
http-nio-443-exec-5, …
Run Code Online (Sandbox Code Playgroud)

java ssl https tomcat

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

无法在c#console应用程序中运行hello world程序

我正在学习C#并为控制台应用程序运行hello world程序.当我使用f5运行时,控制台弹出并立即消失.

    using System;

namespace CSharpConsoleApps
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("hello c sharp world ");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

下面是它在输出中显示的消息

'CSharpConsoleApps.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CSharpConsoleApps.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CSharpConsoleApps.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My …
Run Code Online (Sandbox Code Playgroud)

c#

6
推荐指数
2
解决办法
2万
查看次数

如何在mac osx中将.dex转换为.jar

我正在使用Mac OSX(10.7)并尝试从android apk中提取java文件.所以我下载了apk,然后从http://code.google.com/p/dex2jar/复制了dex2jar文件

从apk(classes.dex)中提取dex文件后,我解压缩了dex2jar并打开了dex2jar的termial更改目录路径并执行如下

my-MacBook-Pro:dex2jar-0.0.9.11 my$ **dex2jar.sh classes.dex**
Run Code Online (Sandbox Code Playgroud)

但它说*-bash:dex2jar.sh:找不到命令*

我在目录中检查并且存在dex2jar.sh.我正在做的错误是什么?

android

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

使用java程序将数据复制到ftp时的文件大小差异

我编写了一个java程序,将文件(*.dmp)格式从我们的服务器复制到FTP服务器.该程序工作正常,它将文件复制到ftp目录.

但只有问题是我复制到FTP后有一点文件大小差异.我的源文件大小是2.47 GB.当我比较MB的文件大小时,在FTP服务器中,大小增加16 MB.我做了两次,它表现出相同的行为.但是当我手动复制到FTP目录(与我们的java程序),文件大小是准确的.

我做错了什么.下面是我的java程序

    package dev.test;

import java.io.*;
import java.io.IOException;
import java.net.SocketException;
import org.apache.commons.net.ftp.*;
public class FTPTest {

      public static void main(String a[]) throws SocketException, IOException
      {
      FTPClient f= new FTPClient();
    f.connect("10.100.8.74");
    boolean flag =f.login("dspetrofac\\admin","admin");
    System.out.println(" is connected ::"+flag);

    // change working directory of FTP Server

    boolean isDirectoryChanged =f.changeWorkingDirectory("IT/Documentum Team/");

    System.out.println(" Is the working directory Changed :: "+isDirectoryChanged);



    // to copy from source to FTP

    InputStream inputFile = new FileInputStream(new File("\\\\dmt500aaashjuae\\testDumpAutomation\\testSiteDump.dmp"));
    boolean isSaved = f.storeFile("testSiteDump.dmp", inputFile);
    System.out.println("is File Saved …
Run Code Online (Sandbox Code Playgroud)

java ftp

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

如何在默认情况下选择标记显示选项而不单击

我已经使用<select>标签创建了一个下拉列表,现在我想在<select>不点击下拉列表的情况下显示选项(我的意思是当我们打开那个html时,我们应该能够看到所有选项而不是点击选择).这可能是使用jQuery或有任何其他方法来做到这一点.

下面是我在jsfiddle中的代码

http://jsfiddle.net/sukumar/xtTcZ/

我希望默认情况下显示如下选项

在此输入图像描述

jquery

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

如何使用java程序将文本文件压缩为rar格式

是否有任何java库可以将纯文本文件(.txt)压缩为winRAR格式(.rar).我一直在谷歌搜索,但找不到任何相关的库,这样做.

java

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

strcpy能否影响strcmp结果的c语言?

编辑:更改标题以反映帖子中的两种方法.

我正在尝试比较c语言中的两个字符串,但由于某种原因,它始终打印两个字符串不相等

#include <stdio.h>
#include <string.h>


int main()
{
    /* A nice long string */

    char test[30]="hellow world";

    char test2[30];

    // to copy string from first array to second array

    strcpy(test2, test);



    /* now comparing two stering*/

    if(strcmp(test2, test))
       printf("strigs are equal  ");
    else

    printf("not equal  \n");

    printf("value of first string  is %s and second string is %s",test,test2);
    printf("length of string1 is %zu and other string is %zu ",strlen(test2),strlen(test2));



}
Run Code Online (Sandbox Code Playgroud)

我总是得到输出

not equal  
value of first string  is hellow world …
Run Code Online (Sandbox Code Playgroud)

c

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

标签 统计

java ×5

android ×1

c ×1

c# ×1

css ×1

ftp ×1

html ×1

https ×1

jquery ×1

regex ×1

ssl ×1

tomcat ×1