我写了一个网络爬虫,它用 keyward 抓取网站,但我想登录到我指定的网站并按关键字过滤信息。如何实现。到目前为止,我已经发布了我的代码。
public class DB {
public Connection conn = null;
public DB() {
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/test";
conn = DriverManager.getConnection(url, "root","root");
System.out.println("conn built");
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public ResultSet runSql(String sql) throws SQLException {
Statement sta = conn.createStatement();
return sta.executeQuery(sql);
}
public boolean runSql2(String sql) throws SQLException {
Statement sta = conn.createStatement();
return sta.execute(sql);
}
@Override
protected void finalize() throws Throwable {
if (conn != …Run Code Online (Sandbox Code Playgroud) 我正在为我的应用程序使用数据表.如何获取数据表中行的总数onload?我的代码:
$(document).ready( function() {
$('#jobSearchResultTable').dataTable({
responsive: true,
"scrollY": 500,
"scrollCollapse": true,
"jQueryUI": true,
"aaSorting": []
});
)};
Run Code Online (Sandbox Code Playgroud)
如何获取数据表中的总行数 onload
根据构造函数的定义,它们没有任何返回类型,但在创建对象时我们经常做A a = new A(); 负责创建对象a.
A a=new A();
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我理解这个问题,在创建Object时构造函数实际发生了什么.
我正在尝试运行一个MR wordcount job.but我得到没有工作jar文件集set.i我发布stacktrace任何人都可以帮助我吗?
14/01/27 16:52:26 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
14/01/27 16:52:26 WARN mapred.JobClient: No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
14/01/27 16:52:26 INFO input.FileInputFormat: Total input paths to process : 1
14/01/27 16:52:26 INFO util.NativeCodeLoader: Loaded the native-hadoop library
14/01/27 16:52:26 WARN snappy.LoadSnappy: Snappy native library not loaded
14/01/27 16:52:27 INFO mapred.JobClient: Running job: job_201401271610_0002
14/01/27 16:52:28 INFO mapred.JobClient: map 0% …Run Code Online (Sandbox Code Playgroud) 我正在一个应用程序中工作,我必须在java类中创建一个html表,并且必须将其保存在数据库中。我正在java中创建该表,但如何在该表中生成动态行。使用3个列表。我是给予我所做的,
+"Interview LineUp"
+" <table border ='1'>"
+"<tr>"
+"<td>Interviewe</td>"
+"<td>Timing1</td>"
+"<td>Timing2</td> "
+"</tr> "
+"<tr>"
+"<td>name</td>"
+"<td>timing1</td> "
+"<td>timing2</td> "
+"</tr> "
+"</table>"
Run Code Online (Sandbox Code Playgroud)
所以这是我在java类中使用的表,我有3个列表,其中包含3组信息,例如名称,timing1,timing2。现在我希望如果所有列表中有3个值,那么将生成3行。
列表是
List<String> interviewTimingToFrom1 = Arrays.asList(interviewTime1.split(","));
List<String> interviewTimingToFrom2 = Arrays.asList(interviewTime2.split(","));
List<String> listOfinterviewerName = Arrays.asList(intervierwName.split(","));
Run Code Online (Sandbox Code Playgroud)
就像我正在这样做
+"<tr>";
for(int k=0;k<listOfinterviewerName .size();k++){
+"<td>listOfinterviewerName .get(k)</td>"
+}
Run Code Online (Sandbox Code Playgroud)
在那个java类中该怎么做?请有人帮忙。提前致谢
我要求我必须拆分具有.xls或.xlsx扩展名的字符串.我必须从本地上传文件并将其保存在我的项目目录中.我能够做到这一点.现在的要求是我必须检查上传的文件是否重复我将更改文件的名称并将扩展名附加到那个.所以我多个客户端访问该文件并尝试上传每个文件的不同名称应该保存到文件夹中.所以我这样做是为了分割Sring,但我不想要这种方法.
public class RenameFile {
public static void main(String[] args) {
String str = new String("Udemy.txt");
String result[] = str.split("\\.");
for (String ff : result) {
System.out.println(ff);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我没有一个循环来操纵我的String.i想要一些只会剪切fileName和ext的东西,我可以将它存储在某处,然后在opeartion后我也可以追加它们.请帮助..
我能够在Apache POI中创建一个表格,我的表格中有适当的值,但我想要的是我想减少表格中列大小的单元格大小如何做,请帮助..这就是什么我做得很好
XWPFTable table = document.createTable(5,3);
r3.setText("MSH Activity Score Card");
r3.setBold(true);
//creating first row
table.getRow(0).getCell(1).setText("Job ID#");
table.getRow(0).getCell(2).setText("1362");
//creating second row
table.getRow(1).getCell(1).setText("Job Title#");
table.getRow(1).getCell(2).setText("Global Network Architect Consultant");
//creating third row
table.getRow(2).getCell(1).setText("Client");
table.getRow(2).getCell(2).setText("Carnival Corporation");
//creating fourth row
table.getRow(3).getCell(1).setText("Start Date");
table.getRow(3).getCell(2).setText("11/13/2014");
//creating fifth row
table.getRow(4).getCell(1).setText("Days Old");
table.getRow(4).getCell(2).setText("33");
CTTblWidth width = table.getCTTbl().addNewTblPr().addNewTblW();
width.setType(STTblWidth.DXA);
width.setW(BigInteger.valueOf(1500));
Run Code Online (Sandbox Code Playgroud)
我正在获取一个包含数据的表,但我希望最小化其大小 
但我想要这个尺寸
我试图执行两个方法,其中两个方法将在一段时间后逐个执行,我正在使用ExecuterService.我已经实现了部分代码但是到目前为止我无法实现的全部功能,在这里我发布了我的代码
public class ExampleExecuterService {
private static final int MYTHREADS = 3000;
public static void main(String[] args) throws Exception {
ExecutorService executor = Executors.newFixedThreadPool(MYTHREADS);
Object methodList[]={
aMethod(),bMethod()
};
for(int i=0;i<methodList.length;i++){
Object myList = methodList[i];
Runnable worker = new MyRunnable(myList);
executor.execute(worker);
}
executor.shutdown();
// Wait until all threads are finish
while (!executor.isTerminated()) {
}
System.out.println("\nFinished all threads");
}
public static class MyRunnable implements Runnable {
private Object myList=null;
MyRunnable(Object myList) {
this.myList = myList;
}
@Override
public void run() …Run Code Online (Sandbox Code Playgroud) 我有一个由三个构造函数组成的类,我的requiremt是我想使用一个单独的对象创建调用所有构造函数.它可能吗?
让我们说
Class A{
A(int a){
}
A(int a,int b){
}
A(int a,int b,int c){
}
Run Code Online (Sandbox Code Playgroud)
我想使用一个对象创建调用所有构造函数,该怎么做?
我正在开发一个应用程序,我必须生成这样的json:
[
{"title":"Culture","start":"Salary","end":"Work"},
{"title":"Work","start":"Salary","end":"Work"}
]
Run Code Online (Sandbox Code Playgroud)
但我的代码生成json像这样:
{{"name":"Culture"},[{"name":"Salary"},{"name":"Work"}],}
Run Code Online (Sandbox Code Playgroud)
我的代码:
public class ParseJson {
public static class EntryListContainer {
public List<Entry> children = new ArrayList<Entry>();
public Entry name;
}
public static class Entry {
private String name;
public Entry(String name) {
this.name = name;
}
}
public static void main(String[] args) {
EntryListContainer elc1 = new EntryListContainer();
elc1.name = new Entry("Culture");
elc1.children.add(new Entry("Salary"));
elc1.children.add(new Entry("Work"));
ArrayList<EntryListContainer> al = new ArrayList<EntryListContainer>();
Gson g = new Gson();
al.add(elc1);
StringBuilder sb = new StringBuilder("{");
for …Run Code Online (Sandbox Code Playgroud) java ×9
apache ×1
apache-poi ×1
constructor ×1
datatable ×1
debugging ×1
excel ×1
hadoop ×1
html ×1
javascript ×1
jquery ×1
json ×1
jsoup ×1
object ×1
web-crawler ×1