我只是想一个转换FileInputStream
到一个InputStream
,我该怎么办呢?
例如
FileInputStream fis = new FileInputStream("c://filename");
InputStream is = ?;
fis.close();
Run Code Online (Sandbox Code Playgroud) 我试图接收一个巨大的文本文件作为输入流,并希望将字符串段转换为另一个字符串.我严格意识到如何做到这一点,如果我将整个输入流转换为字符串,我不想要,因为一些内容丢失,它很有效.谁能请帮忙怎么做?例如,如果我有一个文件,其内容为"这是需要修改的测试字符串".我想接受这个字符串作为输入流,并希望将内容修改为"这是被修改的测试字符串",(通过将'需要'替换为is).
public static void main(String[] args) {
String string = "This is the test string which needs to be modified";
InputStream inpstr = new ByteArrayInputStream(string.getBytes());
//Code to do
}
Run Code Online (Sandbox Code Playgroud)
在这里我希望输出为:这是被修改的测试字符串
提前感谢你.
我在虚拟框中遇到了Arch linux的问题.我已经在VB中安装了Arch linux,但是当我尝试全屏时它不起作用(它只显示在中心的一个小方块中).我试图根据维基安装客户添加,但它仍然无法正常工作.
谁能帮帮我吗?谢谢.
我愿意将xhtml文件转换为pdf/a格式或pdf文件为pdf/a格式..任何人都可以建议我可以使用哪个java库..谢谢
我会让我的例子更具体
我有一个简单的html文件xyz.html
Run Code Online (Sandbox Code Playgroud)<html><body> hello <br> <font style = "Helvetica">hello</font> <br> </body></html>
java代码:
Document document = new Document(PageSize.A4);
FileOutputStream fout = new FileOutputStream(pdffile);
PdfWriter pdfWriter = PdfWriter.getInstance(document, fout);
pdfWriter.setPDFXConformance(PdfWriter.PDFA1B);
FileReader fr = new FileReader(xyz.html);
document.open();
HashMap<String, Object> Provider = new HashMap<String, Object>();
DefaultFontProvider def = new
Provider.put(HTMLWorker.FONT_PROVIDER, def);
HTMLWorker htmlWorker = new HTMLWorker(document);
htmlWorker.setProviders(Provider);
htmlWorker.parse(fr);
Run Code Online (Sandbox Code Playgroud)
我收到错误com.itextpdf.text.pdf.PdfXConformanceException:必须嵌入所有字体.这个不是:Helvetica
我真的很困惑如何通过将其作为参数传递来在jpanel上绘制一个圆圈.
public class test extends JPanel{
public test(JPanel jpanelcomponent) {
}
@Override
protected void paintComponent(Graphics g) {
// TODO Auto-generated method stub
super.paintComponent(g);
int width = getWidth()/2;
int height = getHeight()/2;
g.fillOval(5, 5, width, height);
}
}
Run Code Online (Sandbox Code Playgroud) java ×5
apache-poi ×1
archlinux ×1
excel ×1
inputstream ×1
jpanel ×1
swing ×1
virtualbox ×1
xls ×1