S
SHIRE
Hi,
I want to decode the content of the text file which looks like this:
Subject: =?iso-8859-1?Q?Sek=2Dm=F6te?=
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Vill bara s=E4ga att du hade r=E4tt.
I tried to do it like this:
import java.io.*;
import java.util.*;
import java.net.*;
import java.text.SimpleDateFormat;
public class MessageHandler {
BufferedReader _reader = null;
/**
* Constructor
*/
public MessageHandler(String msgFile){
try {
_reader = new BufferedReader(new InputStreamReader(new
FileInputStream(msgFile), "ISO-8859-1"));
}catch(IOException e){System.out.println(e.toString());}
}
//---------------------------------------------------------------
public void close(){
try {
_reader.close();
}catch(IOException e){
System.out.println(e.toString());
}
}
//-------------------------------------------------------------
public String getFileContent(){
String msg ="";
String line ="";
try{
while((line = _reader.readLine()) != null){
msg += line+"\r\n";
}
}catch(IOException e){
System.out.println(e.toString());
}
return msg;
}
//-------------------------------------------------------------------
public static void main(String args[]){
MessageHandler msgHandler = new MessageHandler("data.txt");
System.out.println("Content:" + msgHandler.getFileContent() );
msgHandler.close();
}
}//End of MessageHandler
But it didn't work.
Please advice.
Thanks for your help.
Mohamud Jama
I want to decode the content of the text file which looks like this:
Subject: =?iso-8859-1?Q?Sek=2Dm=F6te?=
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Vill bara s=E4ga att du hade r=E4tt.
I tried to do it like this:
import java.io.*;
import java.util.*;
import java.net.*;
import java.text.SimpleDateFormat;
public class MessageHandler {
BufferedReader _reader = null;
/**
* Constructor
*/
public MessageHandler(String msgFile){
try {
_reader = new BufferedReader(new InputStreamReader(new
FileInputStream(msgFile), "ISO-8859-1"));
}catch(IOException e){System.out.println(e.toString());}
}
//---------------------------------------------------------------
public void close(){
try {
_reader.close();
}catch(IOException e){
System.out.println(e.toString());
}
}
//-------------------------------------------------------------
public String getFileContent(){
String msg ="";
String line ="";
try{
while((line = _reader.readLine()) != null){
msg += line+"\r\n";
}
}catch(IOException e){
System.out.println(e.toString());
}
return msg;
}
//-------------------------------------------------------------------
public static void main(String args[]){
MessageHandler msgHandler = new MessageHandler("data.txt");
System.out.println("Content:" + msgHandler.getFileContent() );
msgHandler.close();
}
}//End of MessageHandler
But it didn't work.
Please advice.
Thanks for your help.
Mohamud Jama