- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 java 实用程序合并了三个 AFP 文件,该实用程序从文件中读取字节并使用 FileOutputStream
Java 类写入输出流。合并的 AFP 文件看起来不错,但是打开 AFP 文件后,在强制代码 AFPViewer
(在 TLE 浏览器中)中检查 TLE(标签逻辑元素)信息时,所有合并到 GRP 的文件的组编号保持相同: PGP00001
请告诉我如何合并文件,以便 GRP 编号在 AFP 合并后开始按顺序增加。结果应为 GRP:PGP00001、GRP:PGP00002 和 GRP:PGP00003
使用以下代码合并使用 Apache FOP XSL-FO 生成的每个 AFP 文件:
public static byte[] getBytesFromFile(File file) throws IOException {
InputStream is = new FileInputStream(file);
// Get the size of the file
long length = file.length();
// Create the byte array to hold the data
byte[] bytes = new byte[(int)length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file "+file.getName());
}
// Close the input stream and return bytes
is.close();
return bytes;
}
主要功能:
public static void main(String[] args) {
try {
FileOutputStream fos = new FileOutputStream("C:\\dev\\harry\\ETCC_data\\output.afp");
byte[] bytes1 = getBytesFromFile(new File(filePath1));
byte[] bytes2 = getBytesFromFile(new File(filePath2));
fos.write(bytes1);
fos.write(bytes2);
fos.flush();
fos.close();
}
catch(FileNotFoundException ex) { System.out.println("FileNotFoundException : " + ex); }
catch(IOException ioe) { System.out.println("IOException : " + ioe); }
}
最佳答案
afplib 确实有一些关于如何正确地将多个 AFP 文件合并为一个的示例代码:
https://github.com/yan74/afplib/wiki/Samples#afpcombinejava https://github.com/yan74/afplib/blob/master/org.afplib.samples/src/main/java/org/afplib/samples/AfpCombine.java
package org.afplib.samples;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
public class AfpCombineTest {
@Test
public void testRun() throws IOException {
new File("tmp").mkdirs();
AfpCombine combine = new AfpCombine("tmp/out.afp", new String[] { "testdata/start.afp", "testdata/start.afp" , "testdata/ende.afp" , "testdata/ende.afp"});
combine.run();
}
}
关于java - AFP 查看器 TLE 浏览器中的组编号在 AFP 合并后不会按顺序增加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37809969/
我使用 java 实用程序合并了三个 AFP 文件,该实用程序从文件中读取字节并使用 FileOutputStream Java 类写入输出流。合并的 AFP 文件看起来不错,但是打开 AFP 文件后
对于AFP条目 Dijkstra's Shortest Path Algorithm ,证明大纲和证明文件都不存在*。不幸的是,我没有找到 IsaMakefile 来在本地构建这些文档。获取这些文件的
我有一个示例 AFP 文件..想从中读取 TLE(标签逻辑元素)以获取某些预定义标签,例如帐号或帐单号,以便我可以将其转换为特定帐单号的 PDF。还有是否有任何公共(public) Java api
我正在尝试将 AFP 打印到 sysout,但 JCL 不知道(也不知道)FORMS 参数。我目前的解决方案是创建动态 JCL 并将其旋转到 INTRDR,但这是一个薄弱的解决方案,因为该工作不受我们
我有两个 AFP文件,我想将它们连接在一起,我该如何完成。我已经编写了 java 代码来连接它们,使用 BufferedInputStream 和 BufferedOutputStream 结果 AF
我想知道是否可以从我的 iPhone 连接到 AFP(Apple 文件协议(protocol))共享。我的 WiFi 网络中有一个共享,并且想从我的 iPhone 浏览和读取该共享上的文件。 有没有办
我编写了一个应用程序来将一些文件复制到某个位置。它允许用户选择始终位于 AFP 共享上的目的地。这是通过 NSOpenPanel 完成的。返回的 URL 为:file://localhost/Volu
在命令行中,我需要列出本地网络上给定服务器的所有可用 AFP 共享。 我可以浏览提供 AFP 的可用服务器,如下所示: iMac:bin me$ dns-sd -B _afpovertcp._tcp
任何人都可以帮助从 AFP 文件的“字体模式 (FNG)”字段获取文本。是否有任何库(最好是 Java)可以用于此任务? 谢谢, 最佳答案 您可以尝试afplib 。它有一些转储所有结构化字段的示例代
我正在尝试通过 OSX 上的 Java 6 跨安装点获取文件锁: private void tryLockThroughShare() { String path = "/Vo
我正在寻找一个 Java API,它提供将 AFP(IBM 高级功能演示)格式的文档转换为 xml 或 pdf 的功能。我正在尝试实现 Apache FOP 1.1,但几乎没有关于 AFP 的实现文档
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 10年前关闭。 Improve this qu
我使用嵌入式 FOP Trunk 创建了一个 AFP 文件。由于FOP Trunk不支持直接在root下的无操作标签,我需要修改创建的文件以添加NOP记录作为文件中的第一条记录。如何做到这一点? 最佳
使用 python (2.7.3) 在挂载的 afp 卷上写入是否存在已知问题? >f = open("/mnt/foo/test.txt","w+"); 这导致 Traceback (most re
我正在开发一个需要将文件传输到 AFP 卷的应用程序 - 理想情况下,它不会在 OSX 上安装该卷,因为它确实没有必要。 查看 AFP 协议(protocol)内容,我发现了一个旧的 Carbon 头
我有一个在 OSX 上运行的 bash 脚本。 它需要操作网络共享上的一些文件(Synology NAS 上的 AFP 共享)。 不幸的是,脚本运行时有时仍在写入这些文件。 如何确定文件是否正在使用?
我目前正在开发 tvOS/iPhone 应用程序。目标是浏览我的本地网络并找到发布 AFP 和 SMB 共享的不同设备,并从中读取文件。 到目前为止,我已经使用 NSNetServiceBrowser
在 Mac 上,我有一个共享文件夹 ~\Documents。有两个子文件夹:Data 和 Data_2011,前者包含过去几年的文件文件夹,后者包含指向 Data 文件夹中自 2011 年 1 月 1
我是一名优秀的程序员,十分优秀!