首页 > 其他分享 >2023.5.11每日总结

2023.5.11每日总结

时间:2023-05-11 21:46:44浏览次数:33  
标签:11 总结 return String InputStream Blob 2023.5 import new

package get;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

import javax.servlet.http.HttpServletRequest;
import javax.sql.rowset.serial.SerialBlob;
import java.io.*;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.List;

public class Get {
    public Blob f_b(File_ file){//fil_blob
        String FILE="";
        try {
            InputStream InputStream=new FileInputStream(String.valueOf(file));
            int bit;
            while((bit=InputStream.read())!=-1){
                FILE=FILE+Integer.toBinaryString(bit);
            }
            InputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        byte[] buff = FILE.getBytes();
        Blob blob = null;
        try {
            blob = new SerialBlob(buff);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return blob;
    }

    public Blob in_b(InputStream inputStream){//inputstreamתblob
        String FILE="";
        try {
            InputStream InputStream=inputStream;
            int bit;
            while((bit=InputStream.read())!=-1){
                FILE=FILE+Integer.toBinaryString(bit);
            }
            InputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        byte[] buff = FILE.getBytes();
        Blob blob = null;
        try {
            blob = new SerialBlob(buff);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return blob;
    }

    public It enform_getITEM(HttpServletRequest request) throws FileUploadException,IOException {//�õ��ϸ�ҳ����ı��ֶ�
        It it=new It();
        DiskFileItemFactory diskFileItemFactory=new DiskFileItemFactory();
        ServletFileUpload servletFileUpload=new ServletFileUpload(diskFileItemFactory);
        servletFileUpload.setHeaderEncoding("UTF-8");
        List<FileItem> fileItem = servletFileUpload.parseRequest(request);
        for(FileItem item:fileItem) {
            String name_ = item.getFieldName();
            if (item.isFormField()) {
                String value = item.getString("UTF-8");
                Text_ text=new Text_();
                text.setFieldName(name_);
                text.setValue(value);
                it.t.add(text);
            }
            else {
                 InputStream in = item.getInputStream();
                 Blob b=this.in_b(in);
                 File_ file=new File_();
                 file.setFieldName(name_);
                 file.setValue(b);
                 it.f.add(file);
                 in.close();
            }
        }
        return it;
    }
    public String get_text(String FieldName,It it){
        for(Text_ the:it.t){//找出无法识别的原因
            if(FieldName.equals(the.getFieldName())){
                return the.getValue();
            }
        }
        return "";
    }
    public Blob get_file(String FieldName,It it){
        for(File_ the:it.f){
            if(FieldName.equals(the.getFieldName())){
                return the.getValue();
            }
        }
        return null;
    }
//    public Blob enform_Blob_get(HttpServletRequest request, String get) throws IOException,FileUploadException {//�õ��ϸ�ҳ���ļ��ֶ�
//        DiskFileItemFactory diskFileItemFactory=new DiskFileItemFactory();
//        ServletFileUpload servletFileUpload=new ServletFileUpload(diskFileItemFactory);
//        servletFileUpload.setHeaderEncoding("GBK");
//        List<FileItem> fileItem =  servletFileUpload.parseRequest(request);
//        for(FileItem item:fileItem) {
//            String name_ = item.getFieldName();
//            if (!item.isFormField()) {
//                if (get.equals(name_)) {
//                    InputStream in = item.getInputStream();
//                    Blob b=this.in_b(in);
//                    in.close();
//                    return b;
//                }
//            }
//        }
//        return null;
//    }
}

 

标签:11,总结,return,String,InputStream,Blob,2023.5,import,new
From: https://www.cnblogs.com/wllovelmbforever/p/17392326.html

相关文章

  • 每日总结-23.5.11
    <%@pageimport="wangzhan.Thesql"%><%@pageimport="wangzhan.Pd_P_assignment"%><%@pageimport="wangzhan.Pd_S_assignment"%><%@pageimport="wangzhan.Pd_lesson"%><%@pagelanguage=&......
  • Java关键字总结
    finalfinal在Java中是一个保留的关键字,可以声明成员变量、方法、类以及本地变量。final变量对于一个final变量,如果是基本数据类型的变量,则其数值一旦在初始化之后便不能更改;如果是引用类型的变量,则在对其初始化之后便不能再让其指向另一个对象,但是可以改变实例的属性。凡......
  • 每日总结
    遍历文件importjava.io.File;publicclassFileTraversal{publicstaticvoidmain(String[]args){//要遍历的文件路径StringfilePath="C:\\Users\\username\\Documents";//创建File对象,代表要遍历的目录或文件Filefile=newFile(filePath);/......
  • flower in 5.11
    在此,我想探讨一下多项式全家桶应该怎么封装、封装成什么程度的问题。我所认为的多项式全家桶应当是一种全面而又精简、快速而不冗长的一种代码块。最早看到的所谓“多项式全家桶”是Delov半年多前的《简单封装Poly》。非常优雅的马蜂。确实非常优雅的马蜂,相当精简,可读性也极强......
  • Java 编程之美总结
    内容来自王争Java编程之美1、Java基础1、程序本质:代码是如何被执行的?CPU、操作系统、虚拟机各司何职2、基础语法:从CPU角度看变量、数组、类型、运算、跳转、函数等语法3、引用类型:同样都是存储地址,为何Java引用比C/C++指针更安全4、基本类型:既然Java一切皆对......
  • Partitioning by Palindromes - UVa 11584
    例题9-7划分成回文串(PartitioningbyPalindromes,UVa11584)#dp#线性dp#字符串回文#T3输入一个由小写字母组成的字符串,要求把它划分成尽量少的回文串。输出最少的个数。如aaadbccb最少可以划分为3个:aaa,d,bccb输入:第一行输入一个n表示数据组数接下来n行每行输入一个......
  • 5.11
    #include<iostream>#include<string>usingnamespacestd;classPerson{public:Personoperator+(Person&p){Personp3;p3.a=this->a+p.a;p3.b=this->b+p.b;returnp3;}inta;intb;};Personoperator+(Person&p1,Person&......
  • 2023 5 11
    #include<iostream>usingnamespacestd;voidpandaun(inta){inti,t;t=a;//用于储存a的值intA[3];//用于储存各位上的数据for(i=0;i<3;i++){A[i]=a%10;a/=10;}if(t==(A[0]*A[0]*A[0]+A[1]*A......
  • 整体二分总结
    整体二分总结整体二分,就是一种高效离线处理可二分答案的询问的方法,可以代替例如树套树这种高级数据结构。例题:1.P1527[国家集训队]矩阵乘法题意:多次询问,求子矩阵第\(k\)小数。思路:先考虑如果只有一个询问,可以二分答案,把矩阵中小于等于\(mid\)的数赋1,大于的赋0,那么如果子矩阵......
  • 5月11日打卡
    习题4-7题目描述:定义一个Dot类,包含的age、weight等属性,以及对这些属性操作的方法。实现并设计这个类。设计思路:1.定义一个类包含私有类型age、weigh、t共有类型构造函数和输出函数。流程图: 代码部分:#include<iostream>usingnamespacestd;classDot{private:i......