小编Adi*_*Adi的帖子

如何在java中指定的时间延迟后启动一个线程

我已经在ServletContextListener中调用了一个方法作为线程..现在根据我的需要,我必须将线程延迟1分钟,然后开始执行线程中调用的方法,但我无法做到这一点,因为我是非常新的...

这是我的代码......

public class Startup implements ServletContextListener {

@Override
public void contextDestroyed(ServletContextEvent sce) {
}

public void contextInitialized(ServletContextEvent sce) {
    // Do your startup work here
    System.out.println("Started....");
    //captureCDRProcess();
    new Thread(new Runnable() {

        @Override
        public void run() {

            captureCDRProcess();
        }
    }).start();

}
Run Code Online (Sandbox Code Playgroud)

请帮帮我..先谢谢..

java multithreading servletcontextlistener

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

如何在.html标记内附加jQuery变量值

我有一个jquery变量,其中包含用于动态创建复选框的html标记.现在根据我的需要,我必须在jquery的.html标记内添加此变量,以显示对话框内的复选框.此外,我的.html包含表单标记,以包含表单内的复选框代码.

这是我的varbel,其中包含html标签..

var chbx=<input type="checkbox"   id="Mumbai" name="Mumbai" value="Mumbai" />Mumbai<br />
<input type="checkbox"   id=" Delhi" name=" Delhi" value=" Delhi" /> Delhi<br />\
<input type="checkbox"   id=" Bangalore" name=" Bangalore" value=" Bangalore" /> Bangalore<br />
Run Code Online (Sandbox Code Playgroud)

这是我的.html标签包含表单..

var $dialog = $('<div></div>').html("<form id='myform'>" +chbx+ "</form>")
        .dialog({
            autoOpen: false,
            title: 'Select Sites',
            buttons: {
                "Submit": function() {  $('form#myform').submit();},
                "Cancel": function() {$(this).dialog("close");}
            }
        });
Run Code Online (Sandbox Code Playgroud)

我试图将变量添加为+ chbx +,但它没有发生并显示空对话框..

html javascript checkbox jquery

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

如何设置定时器在c#中的特定时间执行

我有一个要求,我需要在每天00:01:00 AM执行计时器...但我没有得到如何实现这一点..如果我正在采取系统时间,它可以是不同的格式..这里是我的计时器代码..

static System.Timers.Timer timer;
timer = new System.Timers.Timer();
timer.Interval = 1000 * 60 * 60 * 24;//set interval of one day
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
start_timer(); 

static void timer_Elapsed(object sender, ElapsedEventArgs e)
    {
        // Add timer code here

    }
    private static void start_timer()
    {
        timer.Start();
    }
Run Code Online (Sandbox Code Playgroud)

c# multithreading timer

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

如何在java中设置itext pdf表alernative rows color

我使用itext pdf库从数据库生成pdf文件.现在我需要我必须以不同颜色显示替代行的pdf表,就像斑马颜色(灰色和白色),但我不知道该怎么做...

这是我的代码..

        PdfPTable table = new PdfPTable(10);
        table.setTotalWidth(100);
        table.setWidthPercentage(100);
        while (rs.next()) {
            table.addCell(rs.getString("date"));
            table.addCell(rs.getString("time"));
            table.addCell(rs.getString("source"));
            table.addCell(rs.getString("destination"));
            table.addCell(rs.getString("extension"));
         }
Run Code Online (Sandbox Code Playgroud)

请帮我.提前致谢.

java pdf itext

6
推荐指数
1
解决办法
4620
查看次数

如何在page.redirect上从servlet到jsp显示成功消息

我在jsp页面中有一个html表单,在提交时将转到servlet ..在servlet中执行函数后,我再次将它重定向到同一个jsp页面,从中调用它成功消息,现在在同一个jsp上显示页面,但我不知道如何做到这一点......

这是我的jsp表单代码..

 <form action="CallTimer" method="GET">
    <label class="button2">Set Date: </label>
    <input type="text" name="date" id="date">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <label class="button2">Set Hour </label>
    <input type="text" name="hour" id="hour">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <label class="button2">Set Minute: </label>
    <input type="text" name="minute" id="minute">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="Submit" name="Submit" value="Submit" id="Submit">
    <br/><br/>
    <label class="button2">Set File-Path: </label>
    <input type="text" name="filepath" id="filepath">
</form>
Run Code Online (Sandbox Code Playgroud)

这是我的servlet重定向代码.

response.sendRedirect("Automail.jsp");
Run Code Online (Sandbox Code Playgroud)

html java jsp servlets

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

如何在itext Pdf中增加PdfPTable的宽度

我正在尝试使用java中的itext pdf库将数据库中的记录导出为pdf.但是我在pdf文件中对齐pdf表时遇到以下问题.

1.Table没有显示在完整的pdf页面中.它是从pdf页面的左侧和右侧留下的空格.

2.每页只显示一半页面的值.Means pdf表显示在一半的pdf页面中.

这是我的代码..

Document document = new Document();
        PdfWriter.getInstance(document, fos);


        PdfPTable table = new PdfPTable(10);

        table.setWidthPercentage(100);
        table.setSpacingBefore(0f);
        table.setSpacingAfter(0f);



        PdfPCell cell = new PdfPCell(new Paragraph("DateRange"));

        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(5.0f);
        cell.setBackgroundColor(new BaseColor(140, 221, 8));

        table.addCell(cell);

        table.addCell("Calldate");
        table.addCell("Calltime");
        table.addCell("Source");
        table.addCell("DialedNo");
        table.addCell("Extension");
        table.addCell("Trunk");
        table.addCell("Duration");
        table.addCell("Calltype");
        table.addCell("Callcost");
        table.addCell("Site");

        while (rs.next()) {
            table.addCell(rs.getString("date"));
            table.addCell(rs.getString("time"));
            table.addCell(rs.getString("source"));
            table.addCell(rs.getString("destination"));
            table.addCell(rs.getString("extension"));
            table.addCell(rs.getString("trunk"));
            table.addCell(rs.getString("dur"));
            table.addCell(rs.getString("toc"));
            table.addCell(rs.getString("callcost"));
            table.addCell(rs.getString("Site"));
        }




        table.setSpacingBefore(5.0f);       // Space Before table starts, like margin-top in CSS
        table.setSpacingAfter(5.0f);        // Space After table starts, like margin-Bottom in CSS                                          

        document.open();//PDF …
Run Code Online (Sandbox Code Playgroud)

java pdf itext

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

如何使用 Java 将生成的 PDF 文件保存到 MySQL 数据库?

我有一个 Java 类,它使用iText库生成 PDF 文件。现在根据我的需要,我必须将此生成的 PDF 文件保存到 MySQL 数据库表中,但我不知道该怎么做。

我的担忧是:

  1. 我应该在 PDF 表的 MySQL 列中使用什么数据类型来保存 PDF 文件
  2. 哪个查询会将生成的 PDF 文件插入到数据库中

目前我正在生成PDF文件并将其存储到本地磁盘的硬编码文件路径中。

这是我用 Java 编写的 PDF 生成代码:

OutputStream file = new FileOutputStream(new File("D://timer.pdf"));
Document document = new Document();
PdfWriter.getInstance(document, file);

//Inserting Table in PDF
PdfPTable table = new PdfPTable(3);

PdfPCell cell = new PdfPCell(new Paragraph("Java4s.com"));

cell.setColspan(3);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setPadding(10.0f);
cell.setBackgroundColor(new BaseColor(140, 221, 8));

table.addCell(cell);

table.addCell("Name");
table.addCell("Address");
table.addCell("Country");
table.addCell("Java4s");
table.addCell("NC");
table.addCell("United States");
table.setSpacingBefore(30.0f);  // Space Before table starts, like …
Run Code Online (Sandbox Code Playgroud)

java mysql pdf

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

在java mail api PasswordAuthentication方法中获取错误

我正在尝试使用java mail api发送邮件.除了Authenticator类之外,代码中的所有东西都可以.它正在发出警告...

Constructor PasswordAuthentication can not be applied to given types.
required java.lang.String,java.lang.char[]
Run Code Online (Sandbox Code Playgroud)

这是我的代码片段,我收到警告错误但无法解决问题...

Authenticator auth = new Authenticator() {

        @Override
        public PasswordAuthentication getPasswordAuthentication() {
 error           return new PasswordAuthentication(userName, password);
        }
    };
      error   Session session = Session.getInstance(properties, auth);
Run Code Online (Sandbox Code Playgroud)

这两行//错误在代码中给出了错误.

请帮我.提前致谢..

java email jakarta-mail

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

如何在Windows窗体应用程序中访问文本文件

我已将一个文本文件添加到Windows窗体应用程序并尝试访问此文件.

这是我的代码..

static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        System.String s = Application.StartupPath+"/Licence.txt";
        System.IO.FileInfo fi = new System.IO.FileInfo(s);

        if (fi.Exists)
        {
            if (fi.Length == 0)
            {
                Application.Run(new Form1());
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

Licence.txt在我的项目文件夹中,但每次(fi.Exists)都是假的,并且程序来自流程而没有显示Form1()窗口..请帮助我.提前致谢..

c# io file-handling windows-forms-designer windows-applications

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

如何连续阅读文本文件

我有一个文本文件,每次都从服务器数据更新.现在按照我的要求,我必须逐行读取这个文件.我知道如何逐行读取文件,但不知道如何连续读取它.这是我的c#代码逐行读取文件...

if (System.IO.File.Exists(FileToCopy) == true)
        {

            using (StreamReader reader = new StreamReader(FileToCopy))
            {
                string line;
                string rawcdr;

                while ((line = reader.ReadLine()) != null)
                {
                   //Do Processing
                }
              }
         }
Run Code Online (Sandbox Code Playgroud)

根据我的要求,我必须连续观看文本文件以进行更改.假设已在文本文件中添加了一个新行,添加它的那一刻应该由上面定义的代码读取,并且应该根据条件执行处理.

c# filesystemwatcher file-handling text-files

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