Java 是否可以像txt一样读取tif文件,删除一些标题行,然后将其保存回tif文件?
我试图删除由扫描仪生成的tif文件内容的前3行,因为我无法正确打开 要删除的行的示例:Java 是否可以像txt一样读取tif文件,删除一些标题行,然后将其保存回tif文件?,java,tiff,Java,Tiff,我试图删除由扫描仪生成的tif文件内容的前3行,因为我无法正确打开 要删除的行的示例: ------=_Part_23XX49_-1XXXX3073.1XXXXX20715 ID: documento<br> MimeType: image/tiff 这个方法告诉我源文件的编码是“Cp1252”,所以我在JVM中放了一个参数(-Dfile.encoding=Cp1252),但没有任何变化 我就是这么做的: StringBuilder fileContent = new String
------=_Part_23XX49_-1XXXX3073.1XXXXX20715
ID: documento<br>
MimeType: image/tiff
这个方法告诉我源文件的编码是“Cp1252”,所以我在JVM中放了一个参数(-Dfile.encoding=Cp1252),但没有任何变化
我就是这么做的:
StringBuilder fileContent = new StringBuilder();
// working with content and save result content in fileContent variable
// save the file again
FileWriter fstreamWrite = new FileWriter(f.getAbsolutePath());
out = new BufferedWriter(fstreamWrite);
out.write(fileContent.toString());
编码是否可能出了问题
如果我使用notepad++进行操作,我将获得一个正确的tiff,可以毫无问题地打开。我发现该库可能对您的要求有用
请看一下自述如何和如何创建tiff文件
希望这能帮助您这不是TIFF文件。它是一个包含TIFF文件的多部分MIME文档,您需要的不是TIFF读取器,而是MIME读取器。
StringBuilder fileContent = new StringBuilder();
// working with content and save result content in fileContent variable
// save the file again
FileWriter fstreamWrite = new FileWriter(f.getAbsolutePath());
out = new BufferedWriter(fstreamWrite);
out.write(fileContent.toString());