I/O / Streams :: POI - Log File To XLSX / Writing Data In Unreadable Format

Jul 16, 2014

When I am trying to read data from BufferedReader and writing into excel using FileOutputStream object with POI APIs then i am getting the data in excel file in bad formats. you can check the log file and excel file attached for more information.

Here my problem is I cannot use BufferedWriter in place of FileOutputStream because POI class XSSFWorkbook only have one write method and we can only pass FileOutputStream class object there.

public void readFile()throws IOException {
BufferedReader inputStream = null;
FileInputStream fis=null;
InputStreamReader isr = null;
//Blank workbook
XSSFWorkbook workbook = new XSSFWorkbook();

[Code] .....

View Replies


ADVERTISEMENT

I/O / Streams :: FileOutputStream Is Not Writing Data To A File?

May 25, 2014

My program creates a file but cannot write to it and i cannot figure out why.

How can i fix this code so that the FileOutputStream writes the String "Output" to the file HighScore.

public boolean ScoreWriter(int HighScore, int ScoreNum){
boolean writ = true;
System.out.println(HighScore + " " + ScoreNum);
try{
File ScoreFile = new File("HighScore");
if (!ScoreFile.exists()){
ScoreFile.createNewFile();
}else if (ScoreFile.exists()){
ScoreFile.delete();
ScoreFile.createNewFile();

[code].....

View Replies View Related

I/O / Streams :: Reading From And Writing To A File Then Read Again Including Data Written

Oct 11, 2014

I'm having a bit of trouble with using the Scanner and the Printwriter. I start with a file like this (1 = amount of Houses in the file)

1
FOR SALE:
Emmalaan 23
3051JC Rotterdam
7 rooms
buyprice 300000
energylevel C

The user gets (let's say for simplicity) 3 options:

1. Add a House to the file,
2. Get all Houses which fullfil requirements (price, FOR SALE / SOLD etc.) and
3. Close the application.

This is how I start:

Scanner sc = new Scanner (System.in);
while (!endLoop) {
System.out.println("Make a choice);
System.out.println("1) Add House");
System.out.println("2) Show Houses");
System.out.println("3) Exit");
int choice = sc.nextInt();

Then I have a switch for all of the three cases. I keep the scanner open, so Java can get the user input (house = for sale or sold, price = ... etc). If the user chose option 1, and all information needed is inputted and scanned, the House will be written to the file (which looks like what I typed above).

For this, I use try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Makelaar.txt", false)))). This works perfectly (at least so it seems.)

If the user chose option 1, and all requirements are inputted and scanned, the Houses will be read (scanner) from the file and outputted. For this I use the same Scanner sc. This also works perfectly (so it seems atleast).

My problem is as follows: If a House has been added, I can only read the House(s) which were already in the file. Let's say I have added 2 houses, and there were from the start 3 houses. If option 2 is chosen, the first 3 houses will be scanned perfectly. An exception will be caught for the remaining 2 (just added) Houses. How can I solve this? I tried to close the Scanner, and reopening it, but apparently Java doesn't agree with this

View Replies View Related

I/O / Streams :: How To Grab Last One Hour Data From Log File

Jul 17, 2014

I have a log file which goes like this..

INFO: Jul 07 00:00:15 DataSource 2zvw8p93107gev14wko86|34e51ca2: Total connections 4 idle 4 busy 0 unclosed orphans 0 pool unknown
PERFORMANCE: Jul 07 00:00:15 Garbage Collection: ParNew 5 51ms in 59 seconds. [SpeedoLoggingBean] Thread SpeedoBean
INFO: Jul 07 00:00:15 Speedo: 2,222,786K of 4,054,528K - 1,831,741K free, 4,952epm, 1 buffered, 216 threads, 49.1% CPU, permgen 173,731K of 262,144K - 88,412K free
Jul 7, 2014 12:00:15 AM org.geotools.data.wfs.v1_0_0.WFSTransactionState commit
SEVERE: number of fids inserted do not match number of fids returned by Transaction Response. Got:1 expected: 0

[code].....

What I need is to grab only the last hour data from this log file?

View Replies View Related

Writing A Sequential Data File?

Dec 15, 2014

I need to write a program that, when a button is pressed, will add the user input to a table AND write it to a sequential data file. I have everything done accept for how to write the data sequentially(all input data on the same line in the file). The following is part of the code:
 
private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel dtm = (DefaultTableModel)jTable1.getModel();
dtm.addRow(new Object[]{donorName.getText(),charityName.getText(),donationAmmount.getText()});
//Adds user input to the table 
try
{
FileWriter writer = new FileWriter("FundraisingInformation.txt",true);//Creates file or adds to it
  BufferedWriter bw = new BufferedWriter(writer);

[code].....

I would need the file output to be in the following format:

donorName charityName donationAmmount

As I said, using the .write(bw) i know how to make it look like:

donorName
charityName
donationAmmount

View Replies View Related

Writing Data To A File Using PrintWriter

Oct 25, 2014

I am creating a car simulator that simulators the odometer and fuel gauge on a car. I want to print the results to a text file but it seems to be printing only the last two lines instead of all of them. How can I make it so it doesn't overwrite the previous input?

Here's my main method:

public static void main(String[] args) throws FileNotFoundException {
CarInstrumentSimulator carInstrumentSimulator = new CarInstrumentSimulator();
FuelGauge gas = carInstrumentSimulator.new FuelGauge();

[Code].....

View Replies View Related

I/O / Streams :: Report Generation Tool For Huge Data In Different File Formats

Apr 8, 2014

I need to generate reports for huge data (around 2 to 5 lakh records) in different file formats (PDF , XLS , RTF , XML) in my web application.

Data will be fetched from database.

I have been searching for a best open source report generation tool and ended up on choosing on Dynamic Reports.

Aspose , is licensed and unluckily we could not afford to at this moment.

Whether i can use Dynamic Reports , or is there any other tool available.

View Replies View Related

I/O / Streams :: Unable To Write Sample Data Into Newly Created File

Nov 29, 2014

My code below creates the 2 files successfully, but it is not able to write the sample data into the newly created file. I can't figure out the reason why.

Another strange thing is that when I tried inserting System.out.println calls for debugging, nothing prints out.

try{
// stuff here
}
catch(FileNotFoundException fileNF){
String dirString = System.getProperty("user.dir");
String defaultFile = "config";
String currentFile = "currentconfig";
Path filePath = Paths.get(dirString, defaultFile);
Path filePath2 = Paths.get(dirString, currentFile);

[Code]...

View Replies View Related

I/O / Streams :: Does Printwriter Always Truncates Existing File To 0 Size Before Adding Any New Data

Jun 13, 2014

Does printwriter always truncates the existing file to 0 size before adding any new data ??

View Replies View Related

Reading Tabular Format Data From PDF File

Feb 20, 2015

I am working on a project where as an input I need to read to data from PDF.

The PDF data will look like

As shown below:

Serial NoName of bookQuanity of BooksLibrary NamePrice

1aaa1London

2bb2Newyork

3cc1Paris

Total number of books4

Payment info

The number of books are dynamic in every pdf which I am going to receive.

View Replies View Related

Read Date From File / Calculate And Then Displays That Data In Table Format On Screen

Apr 22, 2015

The intent of the code is to read date from a file, does calculation and then displays that data in a table format on the screen. Then creates another file with those values:

Reads file: Beginningbalance.txt
Displays Data with calculation
Creates a file called "Newbalance.txt" with the following values:

111
251.41
222
402.00

With the way the code is written I can get it to create the file but it only displays one of the customers (111). I know that I need to create a loop but I am not sure how to build that. I tried creating another while loop and changing it to outFile but that was without success.

import java.io.*;
import java.util.Scanner;
import java.text.DecimalFormat;
public class Output {
public static void main(String[]args) throws IOException {

[Code] .....

View Replies View Related

Writing Data To A Static Table - Can't Populate All Fields With Data

Jun 24, 2015

I have a program which consist of several classes. The program reads a pom file and parses the data and then writes the data to a static table. The issue I'm having is with writing my LIB file data to my table. In the HtmlDataTable Class Im trying to write the files that are read in the lib directory to the table. My table currently consist of 3 columns (missing jar files,Lib Directory files, and POM file data) currently Im only able to write the missing jar files data to my table. In the HtmlDataTable class there is a for statement where I write the missing jar file data to my table. Im also trying to write the contents of the Lib directory within this statement as well. This is where I'm having my issue. My other classes consist of a SAX parser which parses the xml file, a class that creates my static table and a class that compares the jar files in my lib directory to the jar files in my pom file. . Theres a lot of code so I included the parts I felt were useful. If needed I can include the other classes as well.
 
public class ReadPomFile extends DefaultHandler {
public static void main(String[] args) {
try {
// obtain a SAX based parser to parse XML document

[Code].....

View Replies View Related

Add XLSX Files To Netbeans

Sep 5, 2014

I'm running Netbeans 8.0 and attempting to use Apache POI to read various .xlsx files.

Currently, I'm getting a java.io.FileNotFoundException.

I'm using a Mac. What is the correct way to list the file path for my files in Netbeans? Also, is it possible to add the files to my actual project and access them inside the project?

View Replies View Related

Java JOptionPane Text Unreadable

May 17, 2014

When I use this code

import javax.swing.*;
public class Swag {
public static void main ( String[] args) {
String name = JOptionPane.showInputDialog("What is your name?");
  String input = JOptionPane.showInputDialog("How old are you?");
int age = Integer.parseInt(input);
  System.out.print(" Hello, " +name);
System.out.println("Next year you'll be " +(age+1));
}
}

And run it, it ends up looking like thisH1765.png I'm running windows 8, the latest x64 JDK, no type of custom font or anything that I know of. I've run this through eclipse, CMD, and uninstalled and reinstalled Java. I tried using another example of JOptionPane usage from a site and running it, still looks the same.

View Replies View Related

I/O / Streams :: Generate File Tree Structure Of Mounted Unix File System

Apr 22, 2014

I am creating a web application that runs on server X(unix) and it has another unix system mounted on it. I want to generate the file tree structure of this mounted unix file system and show it on to a web application so that users can select a file and move it onto this current unix machine.

I know this sounds stupid and you may want to say why cant we directly copy the file, I am doing a proof of concept and using this as a basis.

View Replies View Related

I/O / Streams :: Retrieving File Directories From A Text File?

Jun 25, 2014

Let's say I have a text file and in the text file exists file directories as such:

'assets/picture1.png'
'assets/picture2.png'

And so on...

How would I then read from this text file and then create those files using 'new File()'?

Here is my code:

private void getFiles() throws IOException{
files = new File[10];
Scanner scan = new Scanner(new File("files.dat"));
int count = -1;

[Code]....

It does print out those files, but it doesn't create them.

View Replies View Related

Need Python For Converting Data Format

Mar 26, 2014

The below is the existing data in a file running over 24768 lines

There are duplicate names link (abc) , width and FLof which stands for offset

file A
------------------
###########################################################################
# F Name Gro Width FLof Class
###########################################################################
1cbb abc - 6 2 INDIRECT
1cbc xyz - 3 0 INDIRECT
1cbd abc - 4 0 INDIRECT
1cf3 bcd - 3 5 INDIRECT
1cf4 pqr - 3 0 INDIRECT
1cf5 bcd - 8 0 INDIRECT
---------
---------- so on

I want a script to convert the file data to as folowing data :

file B
-----------------
###########################################################################
# F Name Gro Width FLof Class
###########################################################################
1cbb abc_7_2 - 6 2 INDIRECT
1cbc xyz - 3 0 INDIRECT
1cbd abc_11_8 - 4 0 INDIRECT
1cf3 bcd_7_5 - 3 5 INDIRECT
1cf4 pqr - 3 0 INDIRECT
1cf5 bcd_15_8 - 8 0 INDIRECT

Explanation for conversion is here :

first row abc has width as 6 and FLof as 2 in file A, so it occupies position 2,3,4,5,6,7 accounting to 6 position so represented as abc_7_2 in file B

Now row three of file A has duplicate of abc so now the new offset will be previous offset plus one ie. position will start from 8 and it goes as follows 8,9,10,11 so represented as abc_11_8

This will create unique and informative names, the same goes with other rows :

</pre> mh_sh_highlight_all('xml');

View Replies View Related

Value Format While Reading Excel Data Into Java

Jan 20, 2015

I am reading Excel data using java apache. I got format issue while reading double value such as 869.87929 (in excel) into 869.8792899999999 (in java).

I'm using following files to read excel data.

1. Schema.csv: SheetName,2-int-Double
2. File.xls:

col1 | col2
123 | 869.87929

Sample code:

if(type.equals("Double")){
String str = content[i-1];
//System.out.println(str);
BigDecimal d = new BigDecimal(str);
listObjects.add(d);
}

Note: type from schema.csv & content [] value from file.xls
If I print **str**, it shows value as 869.8792899999999.
But i need to get **str** value as 869.87929. How can I get it?

View Replies View Related

Java Heap Memory Error While Writing Large Data To Excel

Mar 6, 2014

i have to write more than 100000 rows in a excel sheet (file size more than 20 MB) via java.

when i use XSSF, i am getting below Error.

java.lang.OutOfMemoryError: Java heap space
at org.apache.xmlbeans.impl.store.Saver$TextSaver.resize(Saver.java:1592)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.preEmit(Saver.java:1223)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.emit(Saver.java:1144)

[Code]....

when i use HSSF , i am getting the below Error.
java.lang.OutOfMemoryError: Java heap space

I have tried increasing the java heap size , by giving upto -Xms1500m -Xmx2048m

View Replies View Related

How To Get Date Data Type From MySQL To Java Format

May 22, 2012

In my project i am facing an problem, The My SQL Data base will accept the date format of yyyy/mm/dd only as "Date" data type but in my program i wants to use dd/mm/yyyy format. (i have this same format now) that's why I am unable to insert / retrieve it..

View Replies View Related

I/O / Streams :: Get Specific Value From Txt File

Sep 22, 2014

I know that it's possible to retrieve a line from a txt file but say for example my file looked like this:

staff id = 1
firstname
surname
age

staff id =2
firstname Kate
surname Hollar
age 33

staff id =3
firstname Daniel
surname Hong
age 21

It is possible to retrieve just the staff id's?

View Replies View Related

I/O / Streams :: Clear Old Text Then Add New To File

Aug 12, 2014

I have a code that clear old text then add new text to text file afterthat download the file but the problem my code dose not add new text

FileInputStream fileToDownload ;
private static final int BYTES_DOWNLOAD = 1024;
response.setContentType("text/plain");
String name = request.getParameter("n");
String text = new String(request.getParameter("text").getBytes("iso-8859-1"), "UTF-8");

[Code] ....

How to clear old text then add new text to text file

View Replies View Related

I/O / Streams :: Read € Symbol In A File

Aug 25, 2014

I have a problem with € symbol ... an application write a String content on the file system with following code:

out = new FileOutputStream(strPath + "import.xml");
out.write(trp.getTrpXMLModel().getBytes("ISO-8859-1"));

It's correctly wrote on the file system:

TT;Pierre-H€enri;;Orange Grove;zefezfezfez, Directeur Juridique;TT;;azdaz;01 53 33 56 87;ezfezfez;01 53 33 51 59;.....&ée&ée;;;;;;132;CORDIAL;aaa

But when the application try to read the previous file with following code:

BufferedReader in = new BufferedReader(new InputStreamReader(inStream,"ISO-8859-1"));
String line = in.readLine();

The application isn't able to properly read the symbol ... and return following line, without "€":

TT;Pierre-Henri;;Orange Grove;zefezfezfez, Directeur Juridique;TT;;azdaz;01 53 33 56 87;ezfezfez;01 53 33 51 59;.....&ée&ée;;;;;;132;CORDIAL;aaa

View Replies View Related

I/O / Streams :: File Size Comparison

May 20, 2014

I would like to create a component to detect the file being modify before process.is it the right way to detect the file modification based on file size value?

Below are the flow:

1. Get the file size of a file
2. Used file size value encrypt it with MD5 algorithm, and say it generated us encrypted value "0123sdf"
3. to avoid user modify the file content, before file process, we take the file and do the encryption with md5 again, if it return value "0123sdf", then we are sure it doesn't have modification.

my question:
a. is it the right approach to detect file modification?
b. what the library advise to use or using java.security.DigestInputStream will do?

View Replies View Related

I/O / Streams :: Creating Hidden File

Jul 30, 2006

I want to create hidden files, some sample code for doing this.

View Replies View Related

I/O / Streams :: API To Read Metadata From MP4 File

May 13, 2012

I am looking for a pure java api that can read metadata from an mp4 file, I have looked online but all apis I found are wrappers to native code. How to read mp4 with java .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved