BufferedReader bufferedReader = null
File file = new File("文档地址+文档名.docx")
if(!file.exists()){
} else {
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "读取的字符格式(UTF-8或GBK)"))
String lineText = null
while((lineText = bufferedReader.readLine()) != null){
if (linText != null &&!lineText.eq("")){
System.out.println("一次读取一行,一行内容为:" + lineText)
}
}
}
使用java中的io进行读取BufferedReader bufferedReader = null
File file = new File("文档地址+文档名.docx")
if(!file.exists()){
System.out.println("文件不存在")
} else {
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "读取的字符格式(UTF-8或GBK)"))
String lineText = null
while((lineText = bufferedReader.readLine()) != null){
if (linText != null &&!lineText.eq("")){
System.out.println("一次读取一行,一行内容为:" + lineText)
}
}
}
纯手写的,这里面有点不好写,记得加try,catch还有在finally中释放资源
File file = new File("word file path")byte[] fileByte = new byte[(int)file.length()]//把文件转化成数据流
把fileByte插到数据库就行了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)