Alguem conhece alguma lib ou algum algoritmo capaz de extrair o texto contido num arquivo .doc?
Valewz!
Alguem conhece alguma lib ou algum algoritmo capaz de extrair o texto contido num arquivo .doc?
Valewz!
Tenta algo assim:
/*
* LimpaArquivo.java
*
* Created on 5 de Dezembro de 2006, 11:02
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package limpaarquivo;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
*
* @author igor
*/
public class LimpaArquivo {
/**
* Creates a new instance of LimpaArquivo
*/
public LimpaArquivo() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
LimpaArquivo limpaArquivo = new LimpaArquivo();
limpaArquivo.arrumar();
// TODO code application logic here
}
public void limpar() throws FileNotFoundException, IOException{
FileInputStream stream = new FileInputStream("Teste.txt");
InputStreamReader streamReader = new InputStreamReader(stream);
BufferedReader reader = new BufferedReader(streamReader);
FileWriter fileWriter = new FileWriter("Teste II.txt");
PrintWriter writer = new PrintWriter(fileWriter);
String line = null;
String gravar = "";
while((line=reader.readLine())!=null) {
int i=0;
while(i < line.length()){
if(line.substring(i,i+1).equals(">")){
i++;
if(i < line.length()){
while(!line.substring(i,i+1).equals("<")&& i < line.length()){
gravar = gravar + line.substring(i,i+1).toString();
i++;
}
}
}else
i++;
}
writer.println(gravar);
System.out.println(gravar);
gravar = "";
}
writer.close();
fileWriter.close();
reader.close();
streamReader.close();
stream.close();
System.out.println("OK");
}
public void arrumar() throws FileNotFoundException, IOException{
FileInputStream stream = new FileInputStream("Teste.txt");
InputStreamReader streamReader = new InputStreamReader(stream);
BufferedReader reader = new BufferedReader(streamReader);
FileWriter fileWriter = new FileWriter("Teste II.txt");
PrintWriter writer = new PrintWriter(fileWriter);
String line = null;
String gravar = "";
int i = 1079;
while((line=reader.readLine())!=null) {
gravar = gravar + "(" +i+",59,'" + line + "'), ";
i++;
}
writer.println(gravar);
writer.close();
fileWriter.close();
reader.close();
streamReader.close();
stream.close();
}
}