目前我有以下代码供阅读InputStream
.我将整个文件存储到StringBuilder
变量中,然后处理该字符串.
public static String getContentFromInputStream(InputStream inputStream)
// public static String getContentFromInputStream(InputStream inputStream,
// int maxLineSize, int maxFileSize)
{
StringBuilder stringBuilder = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String lineSeparator = System.getProperty("line.separator");
String fileLine;
boolean firstLine = true;
try {
// Expect some function which checks for line size limit.
// eg: reading character by character to an char array and checking for
// linesize in a loop until line feed is encountered.
// if …
Run Code Online (Sandbox Code Playgroud) 我的目标是连接到防火墙后面的服务器(主机).我可以通过连接到网络中的另一个服务器(隧道)然后SSH到此服务器来访问此服务器.但是我无法通过JSch实现相同的场景.
我无法使用以下代码工作,我为此目的编写了这些代码.如果我在这里做任何蠢事,请告诉我.
public class JschExecutor {
public static void main(String[] args){
JschExecutor t=new JschExecutor();
try{
t.go();
} catch(Exception ex){
ex.printStackTrace();
}
}
public void go() throws Exception{
StringBuilder outputBuffer = new StringBuilder();
String host="xxx.xxx.xxx.xxx"; // The host to be connected finally
String user="user";
String password="passwrd";
int port=22;
String tunnelRemoteHost="xx.xx.xx.xx"; // The host from where the tunnel is created
JSch jsch=new JSch();
Session session=jsch.getSession(user, host, port);
session.setPassword(password);
localUserInfo lui=new localUserInfo();
session.setUserInfo(lui);
session.setConfig("StrictHostKeyChecking", "no");
ProxySOCKS5 proxyTunnel = new ProxySOCKS5(tunnelRemoteHost, 22);
proxyTunnel.setUserPasswd(user, password); …
Run Code Online (Sandbox Code Playgroud) 我的目标是以编程方式调用Refactor >> Rename
Eclipse命令以获取Java源文件中的方法.重命名方法也应该将更改应用于使用/引用此方法的所有实例.
我相信JDT有一个Refactoring API,但是无法找到相同的文档或教程.
有人能指出我正确的方向.
编辑:运行时不需要更改.
我一直在尝试将图像和数据上传到Django服务器.我已经包含apache-mime4j.0.6.jar
和httpmime4.0.1.jar
库(项目 - >构建路径 - >添加外部jar文件)这里是上传图像的代码.
HttpResponse response = null;
try {
HttpPost httppost = new HttpPost("http://10.0.2.2:8000/mobile");
// HttpPost httppost = new HttpPost("some url");
MultipartEntity multipartEntity = new MultipartEntity(); //MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
multipartEntity.addPart("name", new StringBody("nameText"));
multipartEntity.addPart("place", new StringBody("placeText"));
multipartEntity.addPart("tag", new StringBody("tagText"));
//multipartEntity.addPart("Description", new StringBody(Settings.SHARE.TEXT));
multipartEntity.addPart("Image", new FileBody(destination));
httppost.setEntity(multipartEntity);
httpclient.execute(httppost, new PhotoUploadResponseHandler());
} catch (Exception e) {
Log.e( "Error","error");
}
Run Code Online (Sandbox Code Playgroud)
错误信息:
Could not find class 'org.apache.http.entity.mime.MultipartEntity'
Run Code Online (Sandbox Code Playgroud)
我尝试手动创建libs文件夹并手动将jar文件包含到/ libs文件夹中.当我这样做它无法编译.
错误:
Conversion to Dalvik format failed …
Run Code Online (Sandbox Code Playgroud) 我有一个类的IType对象.我想知道这个类是否是一个抽象类.IType或ICompilationUnit中是否有任何方法可用于确定相同的方法(反射除外).
我想在JTree
我的代码中添加一个Swing组件(),它使用SWT.
有什么方法可以实现这个目标吗?
我知道我们TreeViewer
在SWT/Jface中有组件,但我已经开发了一个Jtree实现,并希望添加它,而不是使用TreeViewer重写.
我正在尝试连接配置为使用 ssl 的远程 nginx 服务器。
我发出了一个命令
$curl https://10.73.80.197:8080/
Run Code Online (Sandbox Code Playgroud)
但在那之后我收到错误。这是整个日志-
* Hostname was NOT found in DNS cache
* Trying 10.73.80.197...
* Connected to 10.73.80.197 (10.73.80.197) port 80 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Closing connection 0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Run Code Online (Sandbox Code Playgroud) 我正在运行多个Junit测试,在控制台中运行测试结果被清除并填充当前测试的日志.将存储包含先前测试日志的日志文件.在eclipse中有没有办法,通过它我可以看到这样的删除日志.
如何将.java文件加载到CompilationUnit中?例如,假设我当前项目中有一个A.java文件.我想将它加载到CompilationUnit中,然后将其传递给ASTParser.只是将它作为纯文本加载它不是一个选项,因为在这种情况下我似乎不会获得AST中的绑定信息.
java eclipse abstract-syntax-tree compilationunit eclipse-jdt
如何将FieldDeclaration
(type:ASTNode)转换为IField
(type:JavaElement).是否可以从FieldDeclaration ASTNode获取绑定,就像node.resolveBinding()和MethodDeclaration节点一样.
需要:我正在访问具有公共常量的类中的FieldDeclaration节点,并且想要在项目中搜索该字段的引用.我正在使用JDT的SearchEngine.为此,我想创建一个搜索模式,如下所示:
SearchPattern.createPattern(iField, IJavaSearchConstants.REFERENCES);
Run Code Online (Sandbox Code Playgroud)
我已将此问作为对我的一个问题的评论,但没有得到相同的答案.将其作为单独的问题发布.
在此先感谢您的回答.
回答Deepak的回答.
使用您的方法,我可以检索JavaElement,如下所示
List<VariableDeclarationFragment> fragments = node.fragments();
VariableDeclarationFragment fragment = fragments.get(0);
IJavaElement fieldElement = fragment.resolveBinding().getJavaElement();
Run Code Online (Sandbox Code Playgroud)
如果我传递此IJavaElement来创建搜索模式而不是IField,它将返回与IField相同的结果.
java ×8
eclipse-jdt ×4
eclipse ×2
android ×1
console ×1
curl ×1
dalvik ×1
django ×1
eclipse-rcp ×1
https ×1
jsch ×1
readline ×1
refactoring ×1
ssh ×1
ssh-tunnel ×1
ssl ×1
swing ×1
swt ×1