我有一个Unicode编码的字符串\uXXXX,我想将它转换为常规字母(UTF-8).例如:
String myString = "\u0048\u0065\u006C\u006C\u006F World";
Run Code Online (Sandbox Code Playgroud)
应该成为
"Hello World"
Run Code Online (Sandbox Code Playgroud)
我知道当我打印它显示的字符串时Hello world.我的问题是我从Unix机器上的文件中读取文件名,然后我搜索它们.文件名使用Unicode编码,当我搜索文件时,我找不到它们,因为它搜索\uXXXX名称中的文件.
我正在尝试使用org.apache.http api编写带有SOAP操作的硬编码HTTP Post请求.我的问题是我没有找到添加请求体的方法(在我的情况下 - SOAP动作).我会很高兴得到一些指导.
import java.net.URI;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.RequestWrapper;
import org.apache.http.protocol.HTTP;
public class HTTPRequest
{
@SuppressWarnings("unused")
public HTTPRequest()
{
try {
HttpClient httpclient = new DefaultHttpClient();
String body="DataDataData";
String bodyLength=new Integer(body.length()).toString();
System.out.println(bodyLength);
// StringEntity stringEntity=new StringEntity(body);
URI uri=new URI("SOMEURL?Param1=1234&Param2=abcd");
HttpPost httpPost = new HttpPost(uri);
httpPost.addHeader("Test", "Test_Value");
// httpPost.setEntity(stringEntity);
StringEntity entity = new StringEntity(body, "text/xml",HTTP.DEFAULT_CONTENT_CHARSET);
httpPost.setEntity(entity);
RequestWrapper requestWrapper=new RequestWrapper(httpPost);
requestWrapper.setMethod("POST");
requestWrapper.setHeader("LuckyNumber", "77");
requestWrapper.removeHeaders("Host");
requestWrapper.setHeader("Host", "GOD_IS_A_DJ");
// requestWrapper.setHeader("Content-Length",bodyLength);
HttpResponse response = httpclient.execute(requestWrapper); …Run Code Online (Sandbox Code Playgroud) 我正在使用HttpRequestBase,我想在使用之前将请求完全记录到日志文件中.
默认的toString只返回请求行,我想打印所有标题,参数,请求体等...
有办法吗?
我的 Spring Boot 应用程序上有一个实体:
@Entity
@Table(name = "MY_JOBS")
public class InstallationJobEntity {
@GeneratedValue(generator="SEQUENCE_GENERATOR", strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name="SEQUENCE_GENERATOR",sequenceName="SEQ_MY_JOBS", allocationSize=100)
@Id
@Column(name = "ID")
private Long id;
@Column(name = "CONFIGURATION_DATA")
@Lob
private String configurationData;
public Long getId() {
return id;
}
public String getConfigurationData() {
return configurationData;
}
public void setId(Long id) {
this.id = id;
}
public void setConfigurationData(String configurationData) {
this.configurationData = configurationData;
}
}
Run Code Online (Sandbox Code Playgroud)
为了进行测试,我在 application.yml 上配置 H2 DB:
spring:
jpa:
database: H2
show-sql: true
hibernate:
ddl-auto: none
properties: …Run Code Online (Sandbox Code Playgroud) 我使用了SimpleSwingBrowser示例(http://docs.oracle.com/javafx/2/swing/SimpleSwingBrowser.java.htm)并添加了一些我自己的代码用于日志尾部.
我想为它添加一个搜索栏功能(搜索和突出显示文本).
谷歌搜索了几个小时和自我实验后,我没有找到办法做到这一点.有人可以给我一个开始写这种能力的方向.