java 图片上传from表单必加属性:enctype="multipart/form-data"

1、获取字符串的长度 : length()

2 、判断字符串的前缀或后缀与已知字符串是否相同

前缀 :startsWith(String s)

后缀 :endsWith(String s)

3、比较两个字符串 :equals(String s)

4、把字符串转化为相应的数值

int 型 :Integer.parseInt(字符串)

long 型 :Long.parseLong(字符串)

float 型 : Folat.valueOf(字符串).floatValue()

double 型 :Double.valueOf(字符串).doubleValue()

4、将数值转化为字符串 :valueOf(数值)

5、字符串检索 :indexOf(Srting s)

从头开始检索 :indexOf(String s ,int startpoint) 从 startpoint 处开始检索,如果没有检索到,将返回 -1  (startpoint---- 下标位置)

6、得到字符串的子字符串 :

substring(int startpoint) 从 startpoint 处开始获取

substring(int start,int end) 从 start 到end 中间的字符

7、替换字符串中的字符,去掉字符串前后空格

replace(char old,char new) 用 new 替换 old

trim()

8、分析字符串 StringTokenizer(String s)

构造一个分析器,使用默认分隔字符(空格,换行,回车,Tab,进纸符)

StringTokenizer(String s,String delim) delim 是自己定义的分隔符

nextToken() 逐个获取字符串中的语言符号

boolean hasMoreTokens() 只要字符串还有语言符号将返回 true,否则返回 false

countTokens() 得到一共有多少个语言符号

《输入输出流》

1、FileInputStream类
FileInputStream(String name) 使用给定的文件名name创建一个FileInputStream对象
FileInputStream(File file) 使用File对象创建FileInpuStream对象
File类有两个常用方法:
File(String s) s确定文件名字
File(String directory,String s) directory是文件目录
例如:
File f=new File("Myfile.dat");
FileInputStream istream=new FileInputStream(f);
处理I/O异常
当出现I/O错误的时候,Java生成一个IOException(I/O异常)对象来表示这个错误的信号。
程序必须使用一个catch检测这个异常
例如:
try{
FileInputStream ins= new FileInputStream("Myfile.dat");
}
catch(IOException e){
System.out.println("File read Error:"+e);
}
从输入流中读取字节
int read() 返回0~255之间一个整数,如果到输入流末尾,则返回-1
int read(byte b[]) 读取字节数组
int read(byte b[],int off,int len) off指定把数据存放在b中什么地方,len指定读取的最大字节数
关闭流
close()
2、FileOutputStream类
FileOutputStream(String name) 使用指定的文件名name创建FileOutputStream对象
FileOutputStream(File file) 使用file对象创建FileOutputStream对象
FileOutputStream(FileDescriptor fdobj) 使用FileDescriptor对象创建FileOutputStream对象
3、FileReader类和FileWriter类
FileReader(String filename)
FileWriter(String filename)
处理时需要FileNotFoundException异常
4、RandomAccessFile类
RandomAccessFile不同于FileInputStream和FileOutputStream,不是他们的子类
当我们想对一个文件进行读写操作的时候,创建一个指向该文件的RandomAccessFile流就可以了
RandomAccessFile类有两个构造方法:
RandomAccessFile(String name, String mode) name是文件名,mode取r(只读)或rw(读写)
RandomAccessFile(File file,String mode) file给出创建流的源
seek(long a) 移动RandomAccessFile流指向文件的指针,a确定指针距文件开头的位置
getFilePointer() 获取当前文件的指针位置
close() 关闭文件
getFD() 获取文件的FileDescriptor
length() 获取文件长度
read() 读取一个字节数据
readBoolean() 读取一个布尔值
readByte() 读取一个字节
readChar()
readFloat()
readFully(byte b[])
readInt()
readLine()
readLong()
readUnsignedShort()
readUTF() 读取一个UTF字符串
setLength(long newLength) 设置文件长度
skipByte(int n) 在文件中跳过给定数量的字节
write(byte b[]) 写b.length个字节到文件
writeBoolean(bolean b)
writeByte(int v)
writeChar(char c)
writeChars(String s)
writeDouble(double d)
writeFloat(float v)
writeInt(int i)
writeLong(long l)
writeShort(int i)
writeUTF(String s)
5、管道流
PipedInputStream类
PipedInputStream() 创建一个管道输入流
PipedInputStream(PipedOutputStream a) 连接到输出流a的输入流
read() 从输入流中读取一个字节
read(byte b[],int off,int len) off是在b中的开始位置,len是字节长度
PipedOutputStream类
PipedOutputStream() 创建一个输出流
PipedOutputStream(PipedInputStream a) 连接到输入流a的输出流
write(int b)
write(byte b[],int off,int len)
counnect() 连接输入输出流
close() 关闭流
在使用的时候要捕获IOException异常。
6、数据流
DataInputStream类(数据输入流)
DataInputStream(InputStream in) 将数据输入流指向一个由in指定的输入流
DataOutputStream类(数据输出流)
DataOutputStream(OutputStream out) 将数据输出流指向一个由out指定的输出流
主要方法:
close()
read() 读取一个字节数据
readBoolean() 读取一个布尔值
readByte() 读取一个字节
readChar()
readFloat()
readFully(byte b[])
readInt()
readLine()
readLong()
readUnsignedShort()
readUTF() 读取一个UTF字符串
skipByte(int n) 在文件中跳过给定数量的字节
write(byte b[]) 写b.length个字节到文件
writeBoolean(bolean b)
writeByte(int v)
writeChar(char c)
writeChars(String s)
writeDouble(double d)
writeFloat(float v)
writeInt(int i)
writeLong(long l)
writeShort(int i)
writeUTF(String s)
7、对象流
ObjectInputStream类和ObjectOutputStream类分别是DataInputStream类和DataOutputStream类的子类
8、回压输入流
PushbackInputStream类
PushbackInputStream(InputStream in)
PushbackReader类
PushbackReader(Reader in)
unread(char c) 回压一个字符
unread(char c[]) 回压数组c中全部字符
unread(char c[],offset,int n) 回压c中从offset开始的n个字符

Java 常用方法的更多相关文章

  1. java常用方法总结

    最近打算换工作,还是需要补一下面试的基础知识,写了一些面试中可能会用到的常用算法.方法,以便复习 //99乘法表 /** * 1*1 * 1*1 1*2 * 1*1 1*2 1*3 * …… * */ ...

  2. 22 java常用方法

    /** * 通过正则获取该目录下满足条件的所有目录 * @param luceneFilePathRegular 正则目录,如/user/solrindex/正则表达式 * @return 满足正则表 ...

  3. java常用方法

    public static int byte2int(byte b) { int i = b & 0x07f; if (b < 0) { i |= 0x80; } return i; } ...

  4. java常用方法集合

    1.获取当前日期 // 获取当前日期 public Date getDate(int num) { Calendar cal = new GregorianCalendar(); cal.setTim ...

  5. Spark案例分析

    一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...

  6. java中集合类中Collection接口中的Map接口的常用方法熟悉

    1:Map接口提供了将键映射到值的对象.一个映射不能包含重复的键:每个键最多只能映射到一个值.Map接口中同样提供了集合的常用方法. 2:由于Map集合中的元素是通过key,value,进行存储的,要 ...

  7. Java中从控制台输入数据的几种常用方法

    Java中从控制台输入数据的几种常用方法 一.使用标准输入串System.in //System.in.read()一次只读入一个字节数据,而我们通常要取得一个字符串或一组数字 //System.in ...

  8. Java String类的常用方法

    String(byte[ ] bytes):通过byte数组构造字符串对象. String(char[ ] value):通过char数组构造字符串对象. String(Sting original) ...

  9. Java基础(30):String对象的常用方法与实例(String类)

    Java 中 String 类的常用方法 Ⅰ String 类提供了许多用来处理字符串的方法,例如,获取字符串长度.对字符串进行截取.将字符串转换为大写或小写.字符串分割等,下面我们就来领略它的强大之 ...

随机推荐

  1. for循环递归树

    protected string _menu = string.Empty; public void FirstAnsyData() { try { // List<object> lsN ...

  2. 一、基于hadoop的nginx访问日志分析---解析日志篇

    前一阵子,搭建了ELK日志分析平台,用着挺爽的,再也不用给开发拉各种日志,节省了很多时间. 这篇博文是介绍用python代码实现日志分析的,用MRJob实现hadoop上的mapreduce,可以直接 ...

  3. 在github上搭建hexo博客

    准备工作 安装git 系统是win10家庭版,采用git v1.9.5版本,比较简单,一路next直到finsh完成安装. 安装node.js hexo是基于node.js驱动的一款快速.简单且功能强 ...

  4. 网络抓包wireshark

    抓包应该是每个技术人员掌握的基础知识,无论是技术支持运维人员或者是研发,多少都会遇到要抓包的情况,用过的抓包工具有fiddle.wireshark,作为一个不是经常要抓包的人员,学会用Wireshar ...

  5. MYSQL提权方法

    cve-2016-6662 MYSQL提权分析 MySQL <= 5.7.15 远程代码执行/ 提权 (0day) 5.6.33 5.5.52 Mysql分支的版本也受影响,包括: MariaD ...

  6. PHP中判断变量为空的几种方法

    判断变量为空,在许多场合都会用到,同时自己和许多新手一样也经常会犯一些错误, 所以自己整理了一下PHP中一些常用的.判断变量为空的方法. 1. isset功能:判断变量是否被初始化本函数用来测试变量是 ...

  7. [译]Testing Node.js With Mocha and Chai

    原文: http://mherman.org/blog/2015/09/10/testing-node-js-with-mocha-and-chai/#.ViO8oBArIlJ 为什么要测试? 在此之 ...

  8. Coursera系列-R Programming-Final Week-Assignment3 & 总结

    博客总目录,记录学习R与数据分析的一切:http://www.cnblogs.com/weibaar/p/4507801.html  ------- 经过周末一个半天的努力,终于把这次的Assignm ...

  9. Coursera-Getting and Cleaning Data-week4-R语言中的正则表达式以及文本处理

    博客总目录:http://www.cnblogs.com/weibaar/p/4507801.html Thursday, January 29, 2015 补上第四周笔记,以及本次课程总结. 第四周 ...

  10. 配置SQL server远程连接(局域网)

    具体步骤: 1) 2) 3) 4) 5) 6) 7) 最后为了防火墙有影响,直接把防火关了,测试连接通过在来设置防火墙.