包含javarcfile的词条
今天给各位分享javarcfile的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
java 文件搜索程序
import java.io.File;
import java.io.FileFilter;
public class SearchFile {
private static final class OnlyFile implements FileFilter {
public boolean accept(File pathname) {
if (pathname.isFile()) {
return true;
} else {
return false;
}
}
}
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("使用说明:请输入java SearchFile 目录 文件名");
} else {
File file = new File(args[0]);
File[] files = file.listFiles(new OnlyFile());
for (File f : files) {
if (f.getName().contains(args[1])) {
System.out.println(f.getPath());
}
}
}
}
}
//注意路径名不能有空格
JAVA 如何输出数据到TXT文件内
package test;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import javax.imageio.ImageIO;
public class ReadColorTest {
/**
* 读取一张图片的RGB值
*
* @throws Exception
*/
public void getImagePixel(String image) throws Exception {
File fileCar = new File("D:\\car.txt");
FileOutputStream fos = new FileOutputStream(fileCar);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int[] rgb = new int[3];
File file = new File(image);
BufferedImage bi = null;
try {
bi = ImageIO.read(file);
} catch (Exception e) {
e.printStackTrace();
}
int width = bi.getWidth();
int height = bi.getHeight();
int minx = bi.getMinX();
int miny = bi.getMinY();
System.out.println("width=" + width + ",height=" + height + ".");
bos.write(("width=" + width + ",height=" + height + ".\n").getBytes());
System.out.println("minx=" + minx + ",miniy=" + miny + ".");
bos.write(("minx=" + minx + ",miniy=" + miny + ".\n").getBytes());
for (int i = minx; i width; i++) {
for (int j = miny; j height; j++) {
int pixel = bi.getRGB(i, j); // 下面三行代码将一个数字转换为RGB数字
rgb[0] = (pixel 0xff0000) 16;
rgb[1] = (pixel 0xff00) 8;
rgb[2] = (pixel 0xff);
System.out.println("i=" + i + ",j=" + j + ":(" + rgb[0] + ","+ rgb[1] + "," + rgb[2] + ")");
bos.write(("i=" + i + ",j=" + j + ":(" + rgb[0] + ","+ rgb[1] + "," + rgb[2] + ")\n").getBytes());
}
}
}
/**
* 返回屏幕色彩值
*
* @param x
* @param y
* @return
* @throws AWTException
*/
public int getScreenPixel(int x, int y) throws AWTException { // 函数返回值为颜色的RGB值。
Robot rb = null; // java.awt.image包中的类,可以用来抓取屏幕,即截屏。
rb = new Robot();
Toolkit tk = Toolkit.getDefaultToolkit(); // 获取缺省工具包
Dimension di = tk.getScreenSize(); // 屏幕尺寸规格
System.out.println(di.width);
System.out.println(di.height);
Rectangle rec = new Rectangle(0, 0, di.width, di.height);
BufferedImage bi = rb.createScreenCapture(rec);
int pixelColor = bi.getRGB(x, y);
return 16777216 + pixelColor; // pixelColor的值为负,经过实践得出:加上颜色最大值就是实际颜色值。
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
int x = 0;
ReadColorTest rc = new ReadColorTest();
x = rc.getScreenPixel(100, 345);
System.out.println(x + " - ");
rc.getImagePixel("D:\\car.jpg");
}
}
java如何读取excel中报表(柱状图)的信息
public class Report {
/**作用:报表样式的枚举,该类的getvalue方法返回对应值。br
* Columns_2DVer:2D柱状垂直报表。br
* Columns_3DVer:3D柱状垂直报表。br
* Columns_2DHor:2D柱状水平报表。br
* Columns_3DHor:3D柱状水平报表。
* */
public enum ReportType{
Columns_2DVer("Z2DV"),
Columns_3DVer("Z3DV"),
Columns_2DHor("Z2DH"),
Columns_3DHor("Z3DH"),
LineReport_2D("Line2D"),
LineReport_3D("Line3D"),
PieReport_2D("Pie2D"),
PieReport_3D("Pie3D");
private ReportType(String a){
this.str=a;
}
private String str;
public String getvalue(){
return this.str;
}
}
/**作用:作为创建报表时的参数。br
* 成员1:报表的标题。br
* 成员2:报表的横坐标标题。br
* 成员3:报表的纵坐标标题。br
* 成员4:JSP页面的request对象。br
* 成员5:报表所保存的文件名。br
* 成员6:报表的长度。br
* 成员7:报表的宽度。br
* 成员8:报表的背景颜色,默认为白色。br
* 成员9:报表网格中竖线的颜色,默认为黑色。br
* 成员10:报表网格中横线的颜色,默认为黑色。br
* 成员11:报表横轴内容的数组。br
* 成员12:报表纵轴内容的list数组。br
* 成员13:提示信息。如果写入多个提示信息,报表就变成多柱状。br
* 成员14:报表的模式。详见reportType枚举类br
* 成员15:饼状图专用的数值数组。数组的和必须等于1.br
* 注意1:要在JSP页面引入该类型才能使用,横纵轴数组的长度必须一致。br
* 注意2:如果在提示信息数组中写入了多个提示信息,那么报表纵轴内容的
* list中就必须存放入和它数量一致的int数组。否则会出错。
* */
public class ReportClass{
public String ReportTitle;
public String xTitle;
public String yTitle;
public HttpServletRequest request;
public String filename;
public int width;
public int height;
public Color BackgroundColor=Color.WHITE;
public Color ylineColor=Color.BLACK;
public Color xlineColor=Color.BLACK;
public String[] xValues;
public ArrayListint[] yValue=new ArrayListint[]();
public String[] helpstr;
public String reportType;
public double[] PieValue;
}
/**作用:创建一个指定类型和数据的图表。br
* 参数1:ReportClass类型,各成员具体作用参见ReportClass说明br
* 返回值:String类型,在JSP页面可以直接out.println显示图形。br
* 注意1:ReportClass类型中,必须设置的成员主要有:br
* 1、ReportTitle 2、request 3、filename 4、width 5、height 6、reportTypebr
* 注意2:如果要生成饼状图,还需要设置:br
* 1、xValues 2、PieValue 这两个数组的长度必须一致br
* 注意3:如果要生成柱状图或折线图,还需要设置:br
* 1、xValues 2、yValue 3、helpstrbr
* yvalue数组总和必须等于1.即100%.br
* 如果要生成多柱状或折线图,则需要设置helpstr长度。br
* yvalue列表的长度必须和helpstr数组长度一致。br
* yvalue中的成员数组的长度必须和xvalue数组长度一致。
* */
public String CreateReport(ReportClass rc){
String s="sf";
String str="";
JFreeChart jc=null;
Font titlefont=new Font("宋体",Font.BOLD,20);
Font tickfont=new Font("宋体",0,15);
Font labelfont=new Font("宋体",Font.BOLD,15);
DefaultCategoryDataset ds=null;
DefaultPieDataset pds=null;
if (rc.ReportTitle!=null){
if (rc.reportType.indexOf("Pie")!=-1){//饼状图
pds=new DefaultPieDataset();
double[] ob=rc.PieValue;
for (int i=0;iob.length;i++){
pds.setValue(rc.xValues[i], ob[i]);
}
if (rc.ReportTitle!=null){
if (rc.reportType.equals("Pie2D")){
jc=ChartFactory.createPieChart(rc.ReportTitle,pds,true, true, false);
}
else if (rc.reportType.equals("Pie3D")){
jc=ChartFactory.createPieChart3D(rc.ReportTitle,pds,true, true, false);
}
jc.getTitle().setFont(titlefont);
jc.getLegend().setItemFont(labelfont);
jc.setBackgroundPaint(rc.BackgroundColor);//总背景色
jc.setBorderPaint(rc.BackgroundColor);
PiePlot plot=(PiePlot)jc.getPlot();
plot.setBackgroundPaint(rc.BackgroundColor);
plot.setLabelFont(new Font("宋体",0,15));
}
}
else { //柱状或折线图
ds=new DefaultCategoryDataset();
for (int i=0;irc.helpstr.length;i++){
int[] ob=rc.yValue.get(i);
for (int j=0;job.length;j++){
ds.addValue(ob[j], rc.helpstr[i], rc.xValues[j]);
}
}
if (rc.reportType.indexOf("Z2D")!=-1){
PlotOrientation po=null;
if (rc.reportType.indexOf("V")!=-1){
po=PlotOrientation.VERTICAL;
}
else if (rc.reportType.indexOf("H")!=-1){
po=PlotOrientation.HORIZONTAL;
}
jc=ChartFactory.createBarChart(rc.ReportTitle, rc.xTitle, rc.yTitle,
ds, po, true, true, false);
}
else if (rc.reportType.indexOf("Z3D")!=-1){
PlotOrientation po=null;
if (rc.reportType.indexOf("V")!=-1){
po=PlotOrientation.VERTICAL;
}
else if (rc.reportType.indexOf("H")!=-1){
po=PlotOrientation.HORIZONTAL;
}
jc=ChartFactory.createBarChart3D(rc.ReportTitle, rc.xTitle, rc.yTitle,
ds, po, true, true, false);
}
else if (rc.reportType.equals("Line2D")){
PlotOrientation po=PlotOrientation.VERTICAL;
jc=ChartFactory.createLineChart(rc.ReportTitle, rc.xTitle, rc.yTitle,
ds, po, true, true, false);
}
else if (rc.reportType.equals("Line3D")){
PlotOrientation po=PlotOrientation.VERTICAL;
jc=ChartFactory.createLineChart3D(rc.ReportTitle, rc.xTitle, rc.yTitle,
ds, po, true, true, false);
}
jc.getTitle().setFont(titlefont);
jc.getLegend().setItemFont(labelfont);
jc.setBackgroundPaint(rc.BackgroundColor);//总背景色
CategoryPlot cp=jc.getCategoryPlot();
cp.setBackgroundPaint(rc.BackgroundColor);//图形框架背景色
cp.setDomainGridlinePaint(rc.ylineColor);//图形背景网格中竖线的颜色
cp.setDomainGridlinesVisible(true);
cp.setRangeGridlinePaint(rc.xlineColor);//图形背景网格中横线的颜色
cp.getDomainAxis().setTickLabelFont(tickfont);
cp.getDomainAxis().setLabelFont(labelfont);
cp.getRangeAxis().setTickLabelFont(tickfont);
cp.getRangeAxis().setLabelFont(labelfont);
}
try {
File ff=new File(rc.request.getRealPath("/")+"file");
if (!ff.exists()){
ff.mkdir();
}
File file=new File(rc.request.getRealPath("/")+"file/"+rc.filename);
if (!file.exists()){
file.createNewFile();
}
ChartUtilities.saveChartAsJPEG(file, jc, rc.width, rc.height);
str="img src='"+file.getPath()+"'";
return str;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
else {
return null;
}
}
}
以前写的一个报表的集成,可以生成任何形式的报表,要引入JFreeChar.你可以慢慢研究下...
impala 理论
impala介绍
Cloudera Imapala是一款开源的MPP架构的SQL查询引擎,它提供在hadoop环境上的低延迟、高并发的BI/数据分析,是一款开源、与Hadoop高度集成,灵活可扩展的查询分析引擎,目标是基于SQL提供高并发的即席查询。
与其他的查询引擎系统(如presto、spark sql、hive sql)不同,Impala基于 C++ 和Java编写,支持Hadoop生态下的多种组件集成(如HDFS、HBase、Metastore、YARN、Sentry等),支持多种文件格式的读写(如Parqeut、Avro、RCFile等)。
标准的mpp架构,massively-parallel query execution engine,支持在上百台机器的Hadoop集群上执行快速查询,对底层的存储系统解耦,不像数据库要求那么严格,不同的底层存储可以联合查询。
impala在大数据应用处于什么环节及作用
impala在大数据应用领域中处于数据分析环节,利用mpp架构实现高效数据查询,下游应用系统使用impala也比较多,尤其在应用集市查询数据仓库的时候使用的较多。
impala架构体系
impala由statestore、catalog、impala daemon(impalad)组成。
impala任务执行流程
impala支持的文件格式
Impala可以对Hadoop中大多数格式的文件进行查询,通过create table和insert的方式将一部分格式的数据加载到table中,但值得注意的是,有一些格式的数据它是无法写入的(write to),对于Impala无法写入的数据格式,通常是通过Hive建表,使用Hive进行数据的写入,然后使用Impala来对这些保存好的数据执行查询操作。
impala与hive对比
impala数据类型
海汼部落原创文章,原文链接:()
hsqldb数据库要怎么用
Hsqldb是一个开放源代码的JAVA数据库,其具有标准的SQL语法和JAVA接口,它可以自由使用和分发,非常简洁和快速的。具有Server模式,进程内模式(In-Process)和内存模式(Memory-Only)三种。运行Hsqldb需要hsqldb.jar包, 它包含了一些组件和程序。每个程序需要不同的命令来运行。它位于项目的lib目录下,在介绍这些模式之前需要了解一些Hsqldb所涉及的一些文件。每个Hsqld数据库包含了2到5个命名相同但扩展名不同的文件,这些文件位于同一个目录下。例如,名位"test"的数据库包含了以下几个文件:
•test.properties
•test.script
•test.log
•test.data
•test.backup
properties文件描述了数据库的基本配置。 script文件记录了表和其它数据库对象的定义。log文件记录了数据库最近所做的更新。data文件包含了cached(缓冲)表的数据,而backup文件是将data文件压缩备份,它包含了data文件上次的最终状态数据。所有这些文件都是必不可少的,千万不可擅自删除。但如果你的数据库没有缓冲表(cached table),test.data和test.backup文件是不会存在。
javarcfile的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、javarcfile的信息别忘了在本站进行查找喔。