本文整理汇总了Java中net.sf.jasperreports.engine.util.JRLoader.getLocationInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java JRLoader.getLocationInputStream方法的具体用法?Java JRLoader.getLocationInputStream怎么用?Java JRLoader.getLocationInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jasperreports.engine.util.JRLoader
的用法示例。
在下文中一共展示了JRLoader.getLocationInputStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fill
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
*
*/
public void fill() throws JRException
{
long start = System.currentTimeMillis();
Map<String, Object> parameters = new HashMap<String, Object>();
try
{
JRCsvDataSource xyds = new JRCsvDataSource(JRLoader.getLocationInputStream("data/xyDatasource.csv"), "UTF-8");
xyds.setRecordDelimiter("\r\n");
xyds.setUseFirstRowAsHeader(true);
parameters.put("xyDatasource", xyds);
}
catch (Exception e)
{
throw new JRException(e);
}
JasperFillManager.fillReportToFile("build/reports/XYChart.jasper", new HashMap<String, Object>(parameters), new JREmptyDataSource());
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
示例2: getDataSource
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
/**
*
*/
private static ExcelDataSource getDataSource() throws JRException
{
ExcelDataSource ds;
try
{
String[] columnNames = new String[]{"city", "id", "name", "address", "state"};
int[] columnIndexes = new int[]{0, 2, 3, 4, 5};
ds = new ExcelDataSource(JRLoader.getLocationInputStream("data/XlsDataSource.data.xls"));
// ds.setUseFirstRowAsHeader(true);
ds.setColumnNames(columnNames, columnIndexes);
//uncomment the below line to see how sheet selection works
// ds.setSheetSelection("xlsdatasource2");
}
catch (Exception e)
{
throw new JRException(e);
}
return ds;
}
示例3: copyScript
import net.sf.jasperreports.engine.util.JRLoader; //导入方法依赖的package包/类
protected File copyScript(String scriptLocation)
{
String resourceName = getResourceName(scriptLocation);
try
{
File file = File.createTempFile(TEMP_FILE_PREFIX, "_" + resourceName, tempFolder);
file.deleteOnExit();//TODO lucianc leak
if (log.isDebugEnabled())
{
log.debug("copying " + scriptLocation + " to " + file);
}
byte[] buf = new byte[COPY_BUFFER_SIZE];
try (InputStream input = JRLoader.getLocationInputStream(scriptLocation);
OutputStream output = new FileOutputStream(file))
{
int read = 0;
while ((read = input.read(buf)) > 0)
{
output.write(buf, 0, read);
}
}
return file;
}
catch (IOException | JRException e)
{
throw new JRRuntimeException(e);
}
}