如何正确合并文件?

合并后打印pdf文件时出现以下问题,pdf文档被截断。 有时会发生这种情况,因为文件不是8.5 x 11,它们可能像11 x 17。 我们可以让它检测页面大小,然后对这些文档使用相同的页面大小吗? 或者,如果没有,它是否可以适合页面? 以下是代码: package com.sumit.program; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.itextpdf.text.Document; import com.itextpdf.text.PageSize; import com.itextpdf.text.Rectangle; import com.itextpdf.text.pdf.BaseFont; import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfImportedPage; import com.itextpdf.text.pdf.PdfReader; import com.itextpdf.text.pdf.PdfWriter; public class MergePdf { public static void main(String[] args) { try { […]

将JFreeChart TimeSeries系列与Day数据转换为Week或Month数据?

我意识到这可能是一个愚蠢的问题,我知道可以通过确定每个数据点的周或月等来完成,但是,我正在寻找一种避免编码的方法。 如果它是在一个库中完成的(大概是所有的陷阱都得到了)我宁愿使用它。 原始数据存储在Excel电子表格中,但我无法直接操作电子表格。 如果它是唯一的解决方案,我可以制作副本并操纵它,但这将是最后的手段。 我目前正在将这些数据用于JFreeChart图表,如果这有任何区别的话。 我也愿意使用任何图书馆。 非常感谢您提供任何建议。

如何使用jsp 上传服务器文件夹上的文件

我正在尝试使用servlet / jsp上传一些位于我的服务器上的文件夹上的图像。 下面是我的代码,它在我的本地机器上工作: import java.io.*; import java.util.*; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.io.output.*; public class UploadServlet extends HttpServlet { private boolean isMultipart; private String filePath; private int maxFileSize = 1000 * 1024; private int maxMemSize = 1000 * 1024; private […]

javax.net.ssl.SSLException:收到致命警报:protocol_version

有没有人遇到此错误? 我是SSL的新手,我的ClientHello有什么明显的错误吗? 抛出该exception时没有ServerHello响应。 任何建议表示赞赏。 *** ClientHello, TLSv1 RandomCookie: GMT: 1351745496 bytes = { 154, 151, 225, 128, 127, 137, 198, 245, 160, 35, 124, 13, 135, 120, 33, 240, 82, 223, 56, 25, 207, 231, 231, 124, 103, 205, 66, 218 } Session ID: {} Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, […]

如何从Java程序创建和运行Apache JMeter Test Scripts?

我想使用Apache JMeter提供的API从Java程序创建和运行测试脚本。 我已经理解了ThreadGroup和Samplers的基础知识。 我可以使用JMeter API在我的Java类中创建它们。 ThreadGroup threadGroup = new ThreadGroup(); LoopController lc = new LoopController(); lc.setLoops(5); lc.setContinueForever(true); threadGroup.setSamplerController(lc); threadGroup.setNumThreads(5); threadGroup.setRampUp(1); HTTPSampler sampler = new HTTPSampler(); sampler.setDomain(“localhost”); sampler.setPort(8080); sampler.setPath(“/jpetstore/shop/viewCategory.shtml”); sampler.setMethod(“GET”); Arguments arg = new Arguments(); arg.addArgument(“categoryId”, “FISH”); sampler.setArguments(arg); 但是,我不知道如何创建一个组合线程组和采样器的测试脚本,然后从同一个程序执行它。 有任何想法吗?

JAXB映射对XML的循环引用

我有一个包含循环的对象图。 如何让JAXB处理这个问题? 我尝试在子类中使用@XmlTransient注释,但JAXB marshaller仍然检测到循环。 @Entity @XmlRootElement public class Contact { @Id private Long contactId; @OneToMany(mappedBy = “contact”) private List addresses; … } @Entity @XmlRootElement public class ContactAddress { @Id private Long contactAddressId; @ManyToOne @JoinColumn(name = “contact_id”) private Contact contact; private String address; … }

什么是IndexOutOfBoundsException? 我该如何解决?

这是我的代码: private void bringData() { final TextView mTextView = (TextView) findViewById(R.id.textView); // Instantiate the RequestQueue. RequestQueue queue = Volley.newRequestQueue(this); String url =”http://192.168.4.1:8080/”; // Request a string response from the provided URL. StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener() { @Override public void onResponse(String response) { // Display the first 500 characters of the response […]

Java Swing中的MouseMotionListener,将其与组件内部的组件一起使用

我正在使用Swing中的Touch User界面。 虽然我知道这不是最佳的,但我的截止日期很短,没有时间使用触摸屏特定的GUI包(如果有的话)。 我希望我的用户能够在屏幕上“滑动”他们的手指,并且我制作的特殊JScrollPane的视图随之移动。 代码很简单 – public class PanScrollPane extends JScrollPane implements MouseMotionListener{ public PanScrollPane() { super(); this.addMouseMotionListener(this); } @Override public void mouseDragged(MouseEvent arg0) { System.out.println(“Mouse Dragged!”); } @Override public void mouseMoved(MouseEvent arg0) { System.out.println(“Mouse Moved!”); } 我遇到的问题是JScrollPane是各种JComponents的容器。 当我第一次开始研究这个时,我发现MouseMovedEvent和MouseDraggedEvent会向上传播’GUI树’,直到他们遇到一个带有专门针对该事件的侦听器的Component。 现在看来,我添加到panScrollPane的任何组件都会阻止任何这些MouseMotion事件,让我无法平移。 panScrollPane.add(new JButton(“This thing blocks any mouse motion events”)); 我想用手传播MouseEvent(将侦听器添加到每个组件,然后让它们将事件发送给它们的父组件)将起作用。 然而,这是一项非常耗时的工作,因为我宁愿把时间花在其他事情上,所以我想知道你是否知道任何解决这个问题的方法。 感谢您的阅读,并希望感谢您的回答! 🙂 编辑:让我的意图更清晰。 我只希望panPanel捕获mousemotion事件,任何其他事件(如MouseClick,MouseRelease)应该正常处理

EOFException – 如何处理?

我是一个初学Java程序员,遵循java教程 。 我正在使用Java教程的Data Streams页面中的一个简单Java程序,并且在运行时,它继续显示EOFException 。 我想知道这是否正常,因为读者必须最终到达文件的末尾。 import java.io.*; public class DataStreams { static final String dataFile = “F://Java//DataStreams//invoicedata.txt”; static final double[] prices = { 19.99, 9.99, 15.99, 3.99, 4.99 }; static final int[] units = { 12, 8, 13, 29, 50 }; static final String[] descs = { “Java T-shirt”, “Java Mug”, “Duke Juggling Dolls”, […]

Java正则表达式:重复捕获组

项是一个或多个数字或字符串的逗号分隔列表,例如 “12” “abc” “12,abc,3” 我正在尝试匹配Java中零个或多个项目的括号列表,例如 “” “(12)” “(abc,12)” “(abc,12),(30,asdf)” “(qqq,pp),(abc,12),(30,asdf,2),” 对于最后一个示例,它应分别返回以下匹配组 qqq,pp abc,12 30,asdf,2 我想出了以下(不正确的)模式 \((.+?)\)(?:,\((.+?)\))* 这与上一个示例仅匹配以下内容 qqq,pp 30,asdf,2 提示? 谢谢