This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String byte2bits(byte b) { | |
int z = b; | |
z |= 256; //使最后能截取到8位,而又不影响byte的原来值。 | |
String str = Integer.toBinaryString(z); | |
int len = str.length(); | |
return str.substring(len - 8, len); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void resizeImage(String srcImgPath, String distImgPath, | |
int width, int height) throws IOException { | |
File srcFile = new File(srcImgPath); | |
Image srcImg = ImageIO.read(srcFile); | |
BufferedImage buffImg = null; | |
buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); | |
buffImg.getGraphics().drawImage( | |
srcImg.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, | |
0, null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void floderProcesser() throws IOException { | |
//testfloder是一个文件夹,和.project文件在同一目录下。 | |
String path = "test"; | |
File f=new File(path); | |
File[] list=f.listFiles(); | |
int fileNum = list.length; | |
String name; | |
for(int i = 0;i<fileNum;i++){ | |
name = list[i].getName(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int str2Int(String s) { | |
// method1 | |
int n = Integer.parseInt(s); | |
// method2 | |
int sum = 0; | |
int t = 1; | |
char[] c = s.toCharArray(); | |
for (int i = c.length - 1; i > -1; i--) { | |
sum += (c[i] - '0') * t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding='UTF-8'?> | |
<!DOCTYPE hibernate-mapping PUBLIC | |
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" | |
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > | |
<!-- 以上4行,所有的配置xml文件都一样。 --> | |
<hibernate-mapping package="包名"> | |
<class name="类名" table="表名"> <!-- 每个class元素对应一个持久化对象,即一个数据表。 --> | |
<!-- id元素定义持久化类的标识属性。 --> | |
<id name="类中的字段名" column="对应表中字段" type="类型 "> | |
<generator class="identity"/><!-- 主键生成策略 --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<!DOCTYPE hibernate-configuration PUBLIC | |
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" | |
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> | |
<!-- Hibernate文件头都一样--> | |
<hibernate-configuration> | |
<session-factory> | |
<property name="dialect">org.hibernate.dialect.MySQLDialect</property> | |
<!-- 指定的数据库的url,hibernate连接数据库名,具体而定。 --> | |
<property name="connection.url">dbc:mysql://localhost:3306/countmanagement</property> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewsManager{ | |
public static void main(String[] args) throws Exception{ | |
//实例化Configuration | |
Configuration conf = new Configuration().configure(); | |
//创建SessionFactory | |
SessionFactory sf = conf.buildSessionFactory(); | |
//创建Session | |
Session session = sf.openSession(); | |
//开始事务 | |
Tracsaction tx = sess.beginTransaction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1:使用SHOW语句找出在服务器上当前存在什么数据库: | |
mysql> SHOW DATABASES; | |
2:创建一个数据库MYSQLDATA | |
mysql> CREATE DATABASE MYSQLDATA; | |
3:选择你所创建的数据库 | |
mysql> USE MYSQLDATA; (按回车键出现Database changed 时说明操作成功!) | |
4:查看现在的数据库中存在什么表 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 下载mysql(http://www.mysql.cn/),解压并安装。 | |
若安装之后,可以打开mysql.exe,说明安装成功。 | |
2 打开mysql.exe之后,输入mysql命令,建库/建表/插入... | |
3 下载JDBC驱动(http://mysql.ntu.edu.tw/Downloads/Connector-J/mysql-connector-java-5.0.8.zip) | |
(JDBC驱动是与java程序的接口, 使java语言开发的程序可以连接使用sql数据库。) | |
4 将JDBC驱动(即其中的jar包,在这里叫做mysql-connector-java-5.0.8-bin.jar)导入到工程中: | |
工程上右键,选择Build Path--->Configure Build Path--->Libraries--->Add External JARs--->导入jar包 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set mapred.job.priority=VERY_HIGH; | |
set mapred.job.map.capacity = 1000; | |
set mapred.reduce.capacity=150; |
OlderNewer