Jump to content
Changes to the Jaspersoft community edition download ×

java.io.EOFException for CSV format


manumtl

Recommended Posts

Hello everyone, I am currently on JasperReports-0.6.1-project
And I try to run the example BarbecueApp
As an argument.
Tcsv-
Ftestss-

but when I run it. I have a
java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2230)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2696)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:761)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:128)
    at com.hydroquebec.mac.ssep.ce.util.rapport.jasperreport.BarbecueApp.main(BarbecueApp.java:214)
 
 
but the code is simple

Code:
if (TASK_CSV.equals(taskName))            {File sourceFile = new File(fileName);                               //File sourceFile = new File(contextReportFile);                boolean creer = sourceFile.createNewFile();                if(!creer)                    creer = sourceFile.mkdir();                       JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);                       File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".csv");                               JRCsvExporter exporter = new JRCsvExporter();                               exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);                exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());                               exporter.exportReport();}
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hello gertbeedfrobe, thank to get back to me. I m only try to run the sample BarbecueApp for the version JasperReports-0.6.1-project for a java application. 

 

I think my problem is in the argument

Tcsv-
Ftest

if I put a file name test

a got a message

java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:128)
    at BarbecueApp.main(BarbecueApp.java:206)

NESTED BY :
java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:128)
    at BarbecueApp.main(BarbecueApp.java:206)

NESTED BY :
net.sf.jasperreports.engine.JRException: Error loading object from file : test
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:133)
    at BarbecueApp.main(BarbecueApp.java:206)
Caused by: java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:128)
    ... 1 more

 

if I not put the file

java.io.FileNotFoundException: test
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:117)
    at BarbecueApp.main(BarbecueApp.java:206)

NESTED BY :
java.io.FileNotFoundException: test
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:117)
    at BarbecueApp.main(BarbecueApp.java:206)

NESTED BY :
net.sf.jasperreports.engine.JRException: test
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:117)
    at BarbecueApp.main(BarbecueApp.java:206)
Caused by: java.io.FileNotFoundException: test
    ... 2 more

Code:
/* * ============================================================================ *                   The JasperReports License, Version 1.0 * ============================================================================ *  * Copyright (C) 2001-2004 Teodor Danciu (teodord@users.sourceforge.net). All rights reserved. *  * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: *  * 1. Redistributions of source code must retain the above copyright notice, *    this list of conditions and the following disclaimer. *  * 2. Redistributions in binary form must reproduce the above copyright notice, *    this list of conditions and the following disclaimer in the documentation *    and/or other materials provided with the distribution. *  * 3. The end-user documentation included with the redistribution, if any, must *    include the following acknowledgment: "This product includes software *    developed by Teodor Danciu (http://jasperreports.sourceforge.net)." *    Alternately, this acknowledgment may appear in the software itself, if *    and wherever such third-party acknowledgments normally appear. *  * 4. The name "JasperReports" must not be used to endorse or promote products  *    derived from this software without prior written permission. For written  *    permission, please contact teodord@users.sourceforge.net. *  * 5. Products derived from this software may not be called "JasperReports", nor  *    may "JasperReports" appear in their name, without prior written permission *    of Teodor Danciu. *  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU- * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *//* * ============================================================================ *                   GNU Lesser General Public License * ============================================================================ * * JasperReports - Free Java report-generating library. * Copyright (C) 2001-2004 Teodor Danciu teodord@users.sourceforge.net *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA. *  * Teodor Danciu * 173, Calea Calarasilor, Bl. 42, Sc. 1, Ap. 18 * Postal code 030615, Sector 3 * Bucharest, ROMANIA * Email: teodord@users.sourceforge.net */import java.io.File;import net.sf.jasperreports.engine.JREmptyDataSource;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRExporterParameter;import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperExportManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.JasperPrintManager;import net.sf.jasperreports.engine.JasperRunManager;import net.sf.jasperreports.engine.export.JRCsvExporter;import net.sf.jasperreports.engine.export.JRXlsExporter;import net.sf.jasperreports.engine.export.JRXlsExporterParameter;import net.sf.jasperreports.engine.util.JRLoader;/** * @author Teodor Danciu (teodord@users.sourceforge.net) * @version $Id: BarbecueApp.java,v 1.1 2004/08/18 15:00:42 teodord Exp $ */public class BarbecueApp{	/**	 *	 */	private static final String TASK_COMPILE = "compile";	private static final String TASK_FILL = "fill";	private static final String TASK_PRINT = "print";	private static final String TASK_PDF = "pdf";	private static final String TASK_XML = "xml";	private static final String TASK_XML_EMBED = "xmlEmbed";	private static final String TASK_HTML = "html";	private static final String TASK_XLS = "xls";	private static final String TASK_CSV = "csv";	private static final String TASK_RUN = "run";			/**	 *	 */	public static void main(String[] args)	{		String fileName = null;		String taskName = null;		if(args.length == 0)		{			usage();			return;		}						int k = 0;		while ( args.length > k )		{			if ( args[k].startsWith("-T") )				taskName = args[k].substring(2);			if ( args[k].startsWith("-F") )				fileName = args[k].substring(2);						k++;			}		try		{			long start = System.currentTimeMillis();			if (TASK_COMPILE.equals(taskName))			{				JasperCompileManager.compileReportToFile(fileName);				System.err.println("Compile time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_FILL.equals(taskName))			{				JasperFillManager.fillReportToFile(fileName, null, new JREmptyDataSource());				System.err.println("Filling time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_PRINT.equals(taskName))			{				JasperPrintManager.printReport(fileName, true);				System.err.println("Printing time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_PDF.equals(taskName))			{				JasperExportManager.exportReportToPdfFile(fileName);				System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_XML.equals(taskName))			{				JasperExportManager.exportReportToXmlFile(fileName, false);				System.err.println("XML creation time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_XML_EMBED.equals(taskName))			{				JasperExportManager.exportReportToXmlFile(fileName, true);				System.err.println("XML creation time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_HTML.equals(taskName))			{				JasperExportManager.exportReportToHtmlFile(fileName);				System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_XLS.equals(taskName))			{				File sourceFile = new File(fileName);						JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);						File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");								JRXlsExporter exporter = new JRXlsExporter();								exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);				exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());				exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);								exporter.exportReport();				System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_CSV.equals(taskName))			{				File sourceFile = new File(fileName);						JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);						File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".csv");								JRCsvExporter exporter = new JRCsvExporter();								exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);				exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());								exporter.exportReport();				System.err.println("CSV creation time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else if (TASK_RUN.equals(taskName))			{				JasperRunManager.runReportToPdfFile(fileName, null, new JREmptyDataSource());				System.err.println("PDF running time : " + (System.currentTimeMillis() - start));				System.exit(0);			}			else			{				usage();				System.exit(0);			}		}		catch (JRException e)		{			e.printStackTrace();			System.exit(1);		}		catch (Exception e)		{			e.printStackTrace();			System.exit(1);		}	}	/**	 *	 */	private static void usage()	{		System.out.println( "BarbecueApp usage:" );		System.out.println( "\tjava BarbecueApp -Ttask -Ffile" );		System.out.println( "\tTasks : compile | fill | print | pdf | xml | xmlEmbed | html | xls | csv | run" );	}}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...