本文整理匯總了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);
}
}