我试过代码:
import java.io.Console;
public class Default
{
public static void main(String args[]) throws IOException
{
Console console = System.console();
String testing = console.readLine("Enter Name: ");
System.out.println("Entered Name: "+ testing);
}
}
Run Code Online (Sandbox Code Playgroud)
转到异常,出现以下错误:
Source not found. NullPointerException
我正在使用Eclipse Juno EE进行调试..!
以上编写的代码的参考链接在这里
输入XML:
<foobar>
<Comments>
Reported By: L & A Q TESTING, TESTED
Date of TESTING: Available
TESTING unavailable to resolve Test issue.
Additional Comments: Comments
Had to go into Testing System and change to the correct notification group. Per sup.
</Comments>
</foobar>
Run Code Online (Sandbox Code Playgroud)
XSLT代码:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output indent="no" omit-xml-declaration="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="normalize-space()" />
</xsl:template>
<xsl:template match="text()[../*]"/>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
预期产量:
<foobar><Comments>Reported By: L & A Q TESTING, TESTED Date of TESTING: …
Run Code Online (Sandbox Code Playgroud) 我已经能够使用以下代码永久删除文件:
var DeleteFromDir = new DirectoryInfo(sFromPath);
var files = DeleteFromDir.GetFiles(".txt");
foreach(var file in files)
{
if(bDeletePermanently)
file.Delete();
else
; //Move to recycle bin
}
Run Code Online (Sandbox Code Playgroud)
我在下面试过:
添加对 Microsoft.VisualBasic 程序集的引用。在这个库中可以找到所需的类。
使用 Microsoft.VisualBasic.FileIO 将此 using 语句添加到文件的顶部;
使用 FileSystem.DeleteFile 删除文件,它可以选择是否指定回收站。
但这仅适用于 UI 上下文,而我的应用程序是基于控制台的。
我想出了下面的代码:
String[] labels = {"Name: ", "Fax: ", "Email: ", "Address: "};
int numPairs = labels.length;
JFrame frame = new JFrame("SpringDemo1");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Set up the content pane.
Container contentPane = frame.getContentPane();
SpringLayout layout = new SpringLayout();
contentPane.setLayout(layout);
for (int i = 0; i < numPairs; i++)
{
JLabel lable = new JLabel(labels[i]);
contentPane.add(lable);
contentPane.add(new JTextField(15));
}
//Display the window.
frame.pack();
frame.setVisible(true);
Run Code Online (Sandbox Code Playgroud)
期待:
我得到什么:
默认:
调整大小时:
结果现在与代码实际/通常的样子无关!
我还尝试复制粘贴并运行现成的代码:从这里下载:
结果如下:
是否有任何方法或是否可以在取消选中(Windows窗体)复选框时(但不检查时)编写执行一组指令的方法?我将澄清这提供我的示例代码.
现有样本代码:
private void ChkBox_CheckedChanged(object sender, EventArgs e)
{
if (ChkBox.Checked == false)
{
MessageBox.Show("unchecked");
}
}
Run Code Online (Sandbox Code Playgroud)
问:可以if condition
通过编写一个只在取消选中复选框时执行的方法来避免这种情况.
插图:这样的 事情:
private void ChkBox_Unchecked(object sender, EventArgs e)
{
MessageBox.Show("unchecked");
}
Run Code Online (Sandbox Code Playgroud)
附加评论:我没有任何事情要执行'复选框被检查'.所以只是想我是否可以checkchanged
通过用unchecked
事件类型替换它来避免事件.
我已经能够编写代码来创建新的 PDF 或打开现有的 PDF 并附加。我现在想要实现的是将另一个PDF插入其中。下面是我到目前为止编写的用于附加 PDF 的示例代码。
Document document = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfReader reader = new PdfReader(templateInputStream);
PdfImportedPage page = writer.getImportedPage(reader, 1);
document.newPage();
cb.addTemplate(page, 0, 0);
// Append sample line
document.add(new Paragraph("my timestamp"));
document.close();
Run Code Online (Sandbox Code Playgroud)
据我所知,Adobe Reader 确实支持插入文档。不确定是否也可以使用 Java 代码来实现。
编辑:
下面是我编写的将 PDF 嵌入到 PDF 中的代码。单击并打开嵌入的 pdf/附件时出现错误。
public class AddEmbeddedFile {
public static final String SRC = "C:\\Users\\User\\Desktop\\testSource.pdf";
public static final String Embed = "C:\\Users\\User\\Desktop\\testEmbed.pdf";
public static final String DEST = …
Run Code Online (Sandbox Code Playgroud)