fileoutputstream

Java Swing Apache POI make Word Document read only

五迷三道 提交于 2021-02-19 23:15:56
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

老子叫甜甜 提交于 2021-02-19 23:10:57
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

二次信任 提交于 2021-02-19 23:08:36
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

Java Swing Apache POI make Word Document read only

旧城冷巷雨未停 提交于 2021-02-19 23:08:26
问题 Hello I am creating a Swing application to create a word document. I have made use of the Apache POI Java API for this purpose. But the problem is --> How do I set the word document to be read only after creation? I have heard of java.io.File.setReadOnly() method, but I don't know how to use it in this context. Here is the code: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ FileOutputStream outStream=new FileOutputStream("New.docx"); XWPFDocument doc =new

ext4/fsync situation unclear in Android (Java)

孤人 提交于 2021-02-17 08:48:26
问题 Tim Bray's article "Saving Data Safely" left me with open questions. Today, it's over a month old and I haven't seen any follow-up on it, so I decided to address the topic here. One point of the article is that FileDescriptor.sync() should be called to be on the safe side when using FileOutputStream. At first, I was very irritated, because I never have seen any Java code doing a sync during the 12 years I do Java. Especially since coping with files is a pretty basic thing. Also, the standard

How to delete a line in a .txt file using FileOutputStream?

丶灬走出姿态 提交于 2021-02-10 08:43:15
问题 I need to delete a line from a .txt file stored in the android device's internal storage. I am using FileOutputStream fos = context.openFileOutput("file.txt", Context.MODE_APPEND); to open the .txt file. I already know the line which is to be deleted. How to delete it? Sorry if this question is easy, I looked and couldn't find an answer on Google. 回答1: You can't easily remove a line of text from a file. You can overwrite it with other data which contains the same number of characters, but

Unable to open Excel file after excecuting my java apache poi program and i am using file output stream

折月煮酒 提交于 2021-02-05 11:56:20
问题 I am using Apache poi to extract Mysql data to an Excel file. The code is running correctly but when I am trying to open the excel file it is showing error. package com.telkomsel.excel; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import org.apache.poi.xssf

Unable to open Excel file after excecuting my java apache poi program and i am using file output stream

早过忘川 提交于 2021-02-05 11:56:18
问题 I am using Apache poi to extract Mysql data to an Excel file. The code is running correctly but when I am trying to open the excel file it is showing error. package com.telkomsel.excel; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import org.apache.poi.xssf

FileOutputStream (Apachhe POI) taking too long time to save

☆樱花仙子☆ 提交于 2021-01-28 03:36:28
问题 When I am edit a .xlsx file using Apache poi, its taking too long to save. The .xlsx file contains, formulas formatting and freeze pane. I am using the following code, try { FileInputStream file = new FileInputStream(new File(path)); XSSFWorkbook fWorkbook = new XSSFWorkbook(file); XSSFSheet fSheet = fWorkbook.getSheetAt(0); for(int i = 0; i < jTable1.getRowCount(); i++){ if(jTable1.getModel().getValueAt(i, index1).equals("1")){ XSSFCell cell = fSheet.getRow(i+1).getCell(index1); cell