When the FileWriter.Write method writes a longer string, the actual output is different from the string.

when you use the FileWriter.write (String) method to write a longer string, the actual output is different from the string

Writer is = new FileWriter(urlStr, false);
is.write(sqls);
is.flush();
is.close();

where sqls is:

CREATE TABLE "SUNAOS"."CM_C10001_TB" 
   (
    "F_SSSAS" VARCHAR2(50) NOT NULL ENABLE,
    "F_QWE" VARCHAR2(50) NOT NULL ENABLE,
    "F_WBSJ" VARCHAR2(30) NOT NULL ENABLE,
    "IS_OPEN" CHAR(1) DEFAULT "1" NOT NULL ENABLE,
    "IS_LOCK" VARCHAR2(10) DEFAULT "",
    "LAST_MODI_DATE" CHAR(14) DEFAULT sysdate,
    "BANK_NO" VARCHAR2(50) DEFAULT "SUNYARD",
    "SYSTEM_NO" VARCHAR2(50) DEFAULT "AOS",
    "PROJECT_NO" VARCHAR2(50) DEFAULT "AOS",
    "CUSTOM_NO" VARCHAR2(20) NOT NULL ENABLE
) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "SUNAOS_SM";
COMMENT ON TABLE CM_C10001_TB  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."F_SSSAS"  IS "2";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."F_QWE"  IS "qwe";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."F_WBSJ"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."IS_OPEN"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."IS_LOCK"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."LAST_MODI_DATE"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."BANK_NO"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."SYSTEM_NO"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."PROJECT_NO"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."CUSTOM_NO"  IS "";
INSERT INTO "SUNAOS"."CM_C10001_TB" (F_QWE,BANK_NO,SYSTEM_NO,F_SSSAS,IS_OPEN,IS_LOCK,PROJECT_NO,CUSTOM_NO,LAST_MODI_DATE,F_WBSJ) VALUES ("123","SUNYARD","AOS","1231","1",null,"AOS","20180725133230012001","20180725133324","");
INSERT INTO "SUNAOS"."SM_ELEM_MODULE_TB" (MODULE_NO,DISPLAY_ORDER,DIALOG_CHANGELINE,IS_FORMAT,IS_QUERY,IS_LOCK,CONTROL_WIDTH,BANK_NO,DIALOG_CONTROLWIDTH,SYSTEM_NO,IS_REQUIRED,CHANGE_LINE,IS_OPEN,PROJECT_NO,LAST_MODI_DATE,IS_MODIFY,ELEM_NO) VALUES ("-sharpC10001","2","0","0","0",null,"0","SUNYARD","150","AOS","1","0","1","AOS","SYSDATE       ","1","20180724202236213001");
INSERT INTO "SUNAOS"."SM_ELEM_MODULE_TB" (MODULE_NO,DISPLAY_ORDER,DIALOG_CHANGELINE,IS_FORMAT,IS_QUERY,IS_LOCK,CONTROL_WIDTH,BANK_NO,DIALOG_CONTROLWIDTH,SYSTEM_NO,IS_REQUIRED,CHANGE_LINE,IS_OPEN,PROJECT_NO,LAST_MODI_DATE,IS_MODIFY,ELEM_NO) VALUES ("-sharpC10001","3","0","0","0",null,"0","SUNYARD","150","AOS","1","0","1","AOS","SYSDATE       ","0","20180718135855210001");
INSERT INTO "SUNAOS"."SM_ELEM_MODULE_TB" (MODULE_NO,DISPLAY_ORDER,DIALOG_CHANGELINE,IS_FORMAT,IS_QUERY,IS_LOCK,CONTROL_WIDTH,BANK_NO,DIALOG_CONTROLWIDTH,SYSTEM_NO,IS_REQUIRED,CHANGE_LINE,IS_OPEN,PROJECT_NO,LAST_MODI_DATE,IS_MODIFY,ELEM_NO) VALUES ("-sharpC10001","1","0","0","0",null,"0","SUNYARD","150","AOS","1","0","1","AOS","SYSDATE       ","0","20180720163410639001");
INSERT INTO "SUNAOS"."SM_ELEMENT_TB" (ELEM_CHINESE,IS_LOCK,ELEM_ENGLISH,BANK_NO,DATA_SOURCES,SHOW_TYPE,SYSTEM_NO,IS_OPEN,ELEM_DESC,ADD_WAY,PROJECT_NO,ELEM_LENGTH,SOURCES_TYPE,LAST_MODI_DATE,DATA_TYPE,ELEM_NO) VALUES ("2",null,"f_sssas","SUNYARD",null,"1","AOS","1","","0","AOS","50","1","SYSDATE       ","1","20180718135855210001");
INSERT INTO "SUNAOS"."SM_ELEMENT_TB" (ELEM_CHINESE,IS_LOCK,ELEM_ENGLISH,BANK_NO,DATA_SOURCES,SHOW_TYPE,SYSTEM_NO,IS_OPEN,ELEM_DESC,ADD_WAY,PROJECT_NO,ELEM_LENGTH,SOURCES_TYPE,LAST_MODI_DATE,DATA_TYPE,ELEM_NO) VALUES ("qwe",null,"f_qwe","SUNYARD",null,"1","AOS","1","qwe","0","AOS","50","1","SYSDATE       ","1","20180720163410639001");
INSERT INTO "SUNAOS"."SM_ELEMENT_TB" (ELEM_CHINESE,IS_LOCK,ELEM_ENGLISH,BANK_NO,DATA_SOURCES,SHOW_TYPE,SYSTEM_NO,IS_OPEN,ELEM_DESC,ADD_WAY,PROJECT_NO,ELEM_LENGTH,SOURCES_TYPE,LAST_MODI_DATE,DATA_TYPE,ELEM_NO) VALUES ("",null,"f_wbsj","SUNYARD","organ_name","3","AOS","1",null,"0","AOS","30","5","SYSDATE       ","1","20180724202236213001");

but the actual output has an extra string at the end:

CREATE TABLE "SUNAOS"."CM_C10001_TB" 
   (
    "F_SSSAS" VARCHAR2(50) NOT NULL ENABLE,
    "F_QWE" VARCHAR2(50) NOT NULL ENABLE,
    "F_WBSJ" VARCHAR2(30) NOT NULL ENABLE,
    "IS_OPEN" CHAR(1) DEFAULT "1" NOT NULL ENABLE,
    "IS_LOCK" VARCHAR2(10) DEFAULT "",
    "LAST_MODI_DATE" CHAR(14) DEFAULT sysdate,
    "BANK_NO" VARCHAR2(50) DEFAULT "SUNYARD",
    "SYSTEM_NO" VARCHAR2(50) DEFAULT "AOS",
    "PROJECT_NO" VARCHAR2(50) DEFAULT "AOS",
    "CUSTOM_NO" VARCHAR2(20) NOT NULL ENABLE
) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "SUNAOS_SM";
COMMENT ON TABLE CM_C10001_TB  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."F_SSSAS"  IS "2";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."F_QWE"  IS "qwe";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."F_WBSJ"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."IS_OPEN"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."IS_LOCK"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."LAST_MODI_DATE"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."BANK_NO"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."SYSTEM_NO"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."PROJECT_NO"  IS "";
COMMENT ON COLUMN "SUNAOS"."CM_C10001_TB"."CUSTOM_NO"  IS "";
INSERT INTO "SUNAOS"."CM_C10001_TB" (F_QWE,BANK_NO,SYSTEM_NO,F_SSSAS,IS_OPEN,IS_LOCK,PROJECT_NO,CUSTOM_NO,LAST_MODI_DATE,F_WBSJ) VALUES ("123","SUNYARD","AOS","1231","1",null,"AOS","20180725133230012001","20180725133324","");
INSERT INTO "SUNAOS"."SM_ELEM_MODULE_TB" (MODULE_NO,DISPLAY_ORDER,DIALOG_CHANGELINE,IS_FORMAT,IS_QUERY,IS_LOCK,CONTROL_WIDTH,BANK_NO,DIALOG_CONTROLWIDTH,SYSTEM_NO,IS_REQUIRED,CHANGE_LINE,IS_OPEN,PROJECT_NO,LAST_MODI_DATE,IS_MODIFY,ELEM_NO) VALUES ("-sharpC10001","2","0","0","0",null,"0","SUNYARD","150","AOS","1","0","1","AOS","SYSDATE       ","1","20180724202236213001");
INSERT INTO "SUNAOS"."SM_ELEM_MODULE_TB" (MODULE_NO,DISPLAY_ORDER,DIALOG_CHANGELINE,IS_FORMAT,IS_QUERY,IS_LOCK,CONTROL_WIDTH,BANK_NO,DIALOG_CONTROLWIDTH,SYSTEM_NO,IS_REQUIRED,CHANGE_LINE,IS_OPEN,PROJECT_NO,LAST_MODI_DATE,IS_MODIFY,ELEM_NO) VALUES ("-sharpC10001","3","0","0","0",null,"0","SUNYARD","150","AOS","1","0","1","AOS","SYSDATE       ","0","20180718135855210001");
INSERT INTO "SUNAOS"."SM_ELEM_MODULE_TB" (MODULE_NO,DISPLAY_ORDER,DIALOG_CHANGELINE,IS_FORMAT,IS_QUERY,IS_LOCK,CONTROL_WIDTH,BANK_NO,DIALOG_CONTROLWIDTH,SYSTEM_NO,IS_REQUIRED,CHANGE_LINE,IS_OPEN,PROJECT_NO,LAST_MODI_DATE,IS_MODIFY,ELEM_NO) VALUES ("-sharpC10001","1","0","0","0",null,"0","SUNYARD","150","AOS","1","0","1","AOS","SYSDATE       ","0","20180720163410639001");
INSERT INTO "SUNAOS"."SM_ELEMENT_TB" (ELEM_CHINESE,IS_LOCK,ELEM_ENGLISH,BANK_NO,DATA_SOURCES,SHOW_TYPE,SYSTEM_NO,IS_OPEN,ELEM_DESC,ADD_WAY,PROJECT_NO,ELEM_LENGTH,SOURCES_TYPE,LAST_MODI_DATE,DATA_TYPE,ELEM_NO) VALUES ("2",null,"f_sssas","SUNYARD",null,"1","AOS","1","","0","AOS","50","1","SYSDATE       ","1","20180718135855210001");
INSERT INTO "SUNAOS"."SM_ELEMENT_TB" (ELEM_CHINESE,IS_LOCK,ELEM_ENGLISH,BANK_NO,DATA_SOURCES,SHOW_TYPE,SYSTEM_NO,IS_OPEN,ELEM_DESC,ADD_WAY,PROJECT_NO,ELEM_LENGTH,SOURCES_TYPE,LAST_MODI_DATE,DATA_TYPE,ELEM_NO) VALUES ("qwe",null,"f_qwe","SUNYARD",null,"1","AOS","1","qwe","0","AOS","50","1","SYSDATE       ","1","20180720163410639001");
INSERT INTO "SUNAOS"."SM_ELEMENT_TB" (ELEM_CHINESE,IS_LOCK,ELEM_ENGLISH,BANK_NO,DATA_SOURCES,SHOW_TYPE,SYSTEM_NO,IS_OPEN,ELEM_DESC,ADD_WAY,PROJECT_NO,ELEM_LENGTH,SOURCES_TYPE,LAST_MODI_DATE,DATA_TYPE,ELEM_NO) VALUES ("",null,"f_wbsj","SUNYARD","organ_name","3","AOS","1",null,"0","AOS","30","5","SYSDATE       ","1","20180724202236213001");
,IS_LOCK,CONTROL_WIDTH,BANK_NO,DIALOG_CONTROLWIDTH,SYSTEM_NO,IS_REQUIRED,CHANGE_LINE,IS_OPEN,PROJECT_NO,LAST_MODI_DATE,IS_MODIFY,ELEM_NO) VALUES ("-sharpC1000

the following string:

,IS_LOCK,CONTROL_WIDTH,BANK_NO,DIALOG_CONTROLWIDTH,SYSTEM_NO,IS_REQUIRED,CHANGE_LINE,IS_OPEN,PROJECT_NO,LAST_MODI_DATE,IS_MODIFY,ELEM_NO) VALUES ("-sharpC1000

what is the reason

Apr.03,2021

problem found. It's not the FileWriter problem, it's the time to generate the file and download it

.
InputStream is = new FileInputStream(file);
OutputStream os = response.getOutputStream();
byte[] b = new byte[2048];
while ((is.read(b)) != -1) {
    os.write(b);
}

has bug

Menu