小编ret*_*eto的帖子

如何解决Android中的org.apache.http.conn.ConnectTimeoutException?

我正在从事与服务相关的应用程序.

DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpParams params = httpClient.getParams();
            HttpConnectionParams.setConnectionTimeout(params, 10000000);
            HttpConnectionParams.setSoTimeout(params, 15000000);
            HttpProtocolParams.setUseExpectContinue(httpClient.getParams(),true);

            String str_Server_Host = Control_PWD_Server_Name();
            String requestEnvelope = String.format(envelope_oe);
            // HttpPost httpPost = new HttpPost(str_Server_Host);
            HttpPost httpPost = new HttpPost(str_Server_Host);
            httpPost.setHeader("SOAPAction",
                    "http://tempuri.org/updateTransportStatus");
            httpPost.setHeader("Content-Type", "text/xml;charset=utf-8");
            httpPost.setEntity(new StringEntity(requestEnvelope));
            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();

            line = EntityUtils.toString(httpEntity);
            String str = Html.fromHtml(line).toString();
Run Code Online (Sandbox Code Playgroud)

这是我得到的例外:

org.apache.http.conn.ConnectTimeoutException: Connect to /10.64.0.184:9092 timed out
Run Code Online (Sandbox Code Playgroud)

如何解决android中的上述异常?请提供任何建议或相关的senario.

java android web-services exception connection-timeout

5
推荐指数
0
解决办法
7785
查看次数

hibernate GenerationType.AUTO 在 Oracle 中如何工作?

使用 oracle/JPA Hibernate。我以下面的方式导入了在学生表下具有值的模式。这是例子

100
85
80
70
1
Run Code Online (Sandbox Code Playgroud)

我有以下代码:

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
long id;
Run Code Online (Sandbox Code Playgroud)

现在,当插入新学生时,它不会插入最大值,即 101 (max + 1)。但是在两者之间插入一些可用的值,例如 90。我不确定它怎么可能?

Hibernate 是否在内部创建一些数据库序列并使用然后使用最后创建的值加 1

java oracle hibernate jpa auto-generate

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

在批处理脚本中实现“which”命令

我试图制作一个像which. 所以我想检查这个命令是内部的还是外部的,还是两者兼而有之。我试图执行程序,但是当程序(例如.exe)不正确时,我的程序退出并出现错误,因此我尝试调用help该程序。但是现在,如果我尝试检查例如echo并且我echo.exe在当前目录中有它,我会发现它是外部命令,而不是内部命令。所以我的问题是如何正确地做到这一点。如何检查这个程序是内部的还是外部的。谢谢。这是我的代码:

@echo off
setlocal enabledelayedexpansion
if "%1"=="" goto help

:start
if not "%1"=="" (
    shift
    if "%1"=="/?" goto help 
    goto :start
)
set arg=%*

for %%a in ("%pathext:;=" "%") do (
    echo %arg%|findstr /E /I %%a >nul
    rem If file was given with extension
    if not ERRORLEVEL 1 goto with_rashr
)

set ext=0
for %%a in ("%pathext:;=" "%") do (
    if EXIST "%CD%\!arg!%%~a" (
        echo This is an external command: %CD%\!arg!%%~a …
Run Code Online (Sandbox Code Playgroud)

windows command-line cmd batch-file

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

必须得到字符串ArrayList中的字母数

如果我给出的字符串的ArrayList,即{"hello", "goodbye", "morning", "night"},我该如何检查有多少a的,b的,c的,等有列表中?

该方法必须返回一个ints 数组,其中position [0]是a's 的数字等.例如returnArray[1] = 1,因为b列表中有一个.有没有比仅仅硬编码每个字母更好的方法呢?

public static int[] getLetters( ArrayList<String> list) {
    int [] result = new int[25];
    if(list.contains('a')) {
        result[0] = result[0] + 1;
    }
    return result;
}
Run Code Online (Sandbox Code Playgroud)

有没有比再重复上述策略25次更好的方法?

java arraylist

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

如何使用poi jar读取java api中的docx文件内容

我已经阅读了doc文件,现在我正在尝试阅读docx文件内容.当我搜索样本代码时,我发现很多,没有任何效果.检查代码以供参考......

import java.io.*;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;

public class createPdfForDocx {

public static void main(String[] args) {
InputStream fs = null;  
    Document document = new Document();
    XWPFWordExtractor extractor = null ;

try {

    fs = new FileInputStream("C:\\DATASTORE\\test.docx");
    //XWPFDocument hdoc=new XWPFDocument(fs);
    XWPFDocument hdoc=new XWPFDocument(OPCPackage.open(fs));
    //XWPFDocument hdoc=new XWPFDocument(fs);
    extractor = new XWPFWordExtractor(hdoc);
    OutputStream fileOutput = new FileOutputStream(new       File("C:/DATASTORE/test.pdf"));
    PdfWriter.getInstance(document, fileOutput);
    document.open();
    String fileData=extractor.getText();
    System.out.println(fileData);
    document.add(new Paragraph(fileData));
    System.out.println(" pdf document created");
        } catch(IOException e) {
            System.out.println("IO Exception"); …
Run Code Online (Sandbox Code Playgroud)

java docx apache-poi readfile

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

列表设置而不影响元素的顺序

我有一个字符串列表 ["abc", "xyz", "abc", "mno", "123"]

现在我想要这个列表中的唯一值.为此,我将List转换为HashSet.

我能够实现相同但元素的顺序受到影响.输出是非常随机的,其中一个结果是["123", "xyz", "abc", "mno"].

但我希望结果集包含与arraylist相同顺序的项目.我怎样才能做到这一点?

List<String> parameters = new ArrayList<String>();
//add the parameter to List
Set<String> parameterSet=new HashSet<String>(parameters);
Run Code Online (Sandbox Code Playgroud)

java arraylist set

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

在Haskell中按长度过滤列表项

我有一个清单 ["a","ab","abc", "abcd"]

如何获取仅包含长度> 2的项目的列表.

意味着结果是 ["abc","abcd"].

haskell

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

jaxb2-maven-plugin为默认值= INF的双精度生成无效源

我有一个问题,当XSD文件包含双精度的默认值时,jaxb2-maven-plugin会生成无效的源代码.

我使用jaxb2-maven-plugin(org.codehaus.mojo)1.5版:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.5</version>
    <configuration>
    </configuration>
    <executions>
        <execution>
            <id>analysis_jaxb</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>xjc</goal>
            </goals>
            <configuration>
                <clearOutputDir>false</clearOutputDir>
                <schemaFiles>Analysis.xsd</schemaFiles>
                <packageName>xx.xx.xx.analysis</packageName>
                <generateDirectory>${project.build.directory}/generated-sources/jaxb/analysis</generateDirectory>
                <verbose>true</verbose>
            </configuration>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

从以下XSD文件生成Java Source:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

    <xs:element name="MinMax" type="MinMaxType"/>

    <xs:complexType name="MinMaxType">
        <xs:attribute name="min" type="xs:double" default="-INF" />
        <xs:attribute name="max" type="xs:double" default="INF" />
    </xs:complexType>

</xs:schema> 
Run Code Online (Sandbox Code Playgroud)

生成的Java文件包含以下方法:

public double getMin() {
    if (min == null) {
        return -InfinityD; //UNDEFINED
    } else {
        return min;
    }
}
Run Code Online (Sandbox Code Playgroud)

该字段-InfinityD未在任何地方定义.

使用布尔值(例如<xs:attribute name="minInclusive" type="xs:boolean" default="false" />)时,默认值按预期工作.

与此相反,插件 …

xsd jaxb maven maven-jaxb2-plugin jaxb2-maven-plugin

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

正则表达式将字符串分成句子

我需要拆分包含句子的字符串,例如:

"this is a sentence. this is another. Rawlings, G. stated foo and bar." 
Run Code Online (Sandbox Code Playgroud)

["this is a sentence.", "this is another.", "Rawlings, G. stated foo and bar."] 
Run Code Online (Sandbox Code Playgroud)

使用正则表达式.

我找到的其他解决方案将第三句分成了"Rawlings, G.","stated foo and bar."这不是我想要的.

java regex string

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

将String数组添加到ArrayList中

我想追加ab字符串数组到arrayList.但"1.0"必须"1"与拆分一起使用.Split方法返回String [],因此arrayList add方法不能像这样工作.你能建议其他任何方式吗?

String[] a = {"1.0", "2", "3"};
String[] b = {"2.3", "1.0","1"};

ArrayList<String> arrayList = new ArrayList<String>();

arrayList.add(a[0].split("."));
Run Code Online (Sandbox Code Playgroud)

java arrays string split

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