import java.io.*;
class runExtApp{
String arr[]=null;
public void runfunc(){
try{
Runtime.getRunt ime().exec("oow riter -o /home/the exact path where your file exists");
}catch(IOExcept ion e){
System.out.prin tln(e);
}
}
}
public class Mainpro{
public static runExtApp runapp =new runExtApp();
public static void main(String[]args){
runapp.runfunc( );
}
}
if possible plz mail me your font converter program i will check it out l8r.....
<email removed use PMs :ADMIN>
Hello,
I think you have not got my problem.I dont want to open .doc file directely.
My program should be read that .doc file. Then program should able to get
only specific font(say marathi,hindi.d vbttyogesh) data from that file and convert it to unicode.
At this stage my program converts all file contents to unicode.
Following is my program......
package GuiProjectPac;
import java.io.*;
import java.util.*;
import java.net.*;
public class FileJavaNew5
{ //%%%%%% Command line arg with expection%%%%%
/*public String args[0];
public String args1;
public String args2;*/
public static HashMap mp= new HashMap();
public static TreeSet ts =new TreeSet();
public static TreeMap tm =new TreeMap();
public static Set set;
public static Vector vec= new Vector();
public static boolean DEBUG =false;
public static String delim = "\r\t\n ";
public static String map="";
public static String ip="";
public static String op="";
public static class CusResult {
public String lbound;
public String ubound;
public int ret=0;
public CusResult() {
lbound = "";
ubound = "";
ret = 0;
}
public String getLBound() {
return lbound;
}
public String getUBound() {
return ubound;
}
public int getRet() {
return ret;
}
public void setLBound(Strin g l) {
lbound = l;
}
public void setUBound(Strin g u) {
ubound = u;
}
public void setRet(int r) {
ret = r;
}
}
public static void Conmain (String arg1,String arg2,String arg3)
{
map=arg1;
ip=arg2;
op=arg3;
//System.out.prin tln("Fist give map file then Input file & OutputFile");
/* int i=args.length;
int j=3;
System.out.prin tln(i);*/
try
{
/*if(args.length ==3)
System.out.prin tln(" ok");
else
System.out.prin tln(" plz Give Totle Paramerter as Mention");
*/
FileInputStream fin;
String tk=null;
fin = new FileInputStream (map);
DataInputStream in = new DataInputStream (fin);
while (in.available() !=0)
{
tk = in.readLine();
StringTokenizer st = new StringTokenizer (tk," \n");
while(st.hasMor eTokens())
{
String key= st.nextToken();
String val= st.nextToken();
tm.put(key,val) ;//Entered value in Map
}
}
//System.out.prin tln("Asending Map :");
Set set = tm.entrySet();
Iterator tit =set.iterator() ;
while(tit.hasNe xt()){
Map.Entry me =(Map.Entry)tit .next();
//System.out.prin tln(me.getKey() +":"+me.getValu e());
}
fin.close();
}
catch (IOException e)
{
System.err.prin tln ("Unable to read from file1");
System.exit(-1);
}
catch (ArrayIndexOutO fBoundsExceptio n e)
{
System.err.prin tln ("it catch "+e);
System.exit(-1);
}
//mappingFileBegi n();//call to vector map funct1ion
//System.out.prin tln("Vec :"+vec.firstEle ment().toString ());
//opening input file
FileInputStream finIn;
FileOutputStrea m finOut;
String line=null;
String uniLine=null;
try
{
finIn = new FileInputStream (ip);
DataInputStream in = new DataInputStream (finIn);
finOut = new FileOutputStrea m (op);
DataOutputStrea m out = new DataOutputStrea m(finOut);
while (in.available() !=0)
{
line = in.readLine();
uniLine=convert Line(line);
//out.writeChars( uniLine);
out.writeBytes( uniLine);
out.writeByte(' \n');
//out.writeUTF(un iLine);
}
finIn.close();
finOut.close();
if(uniLine.leng th()>0)
{
//System.out.prin tln("o/p File Contents:"+uniL ine);
// outfptr<<uniLin e<<endl;
}}
catch (IOException e)
{
System.err.prin tln ("Unable to read from file 2");
System.exit(-1);
}
catch (ArrayIndexOutO fBoundsExceptio n e)
{
System.err.prin tln ("yogesh"+e) ;
System.exit(-1);
}
}
public static boolean isdelim(char ch){
for(int i=0;i<delim.len gth();i++)
{
if(delim.charAt (i)==ch)
return true;
}
return false;
// return(delim.co ntains(ch));
}
public static String convertLine(Str ing line)
{ char linechar[]=line.toCharArr ay();
int len = line.length();
String word="";
String uniWord="";
String uniLine="";
if(line.length( )==0)
return "";
if(DEBUG)
{
System.out.prin tln("Input Line:"+line);
System.out.prin tln("Length Of Input Line:"+len);
}
for(int i=0;i<len;i++){
if(isdelim(line char[i])){
if(word.length( )!=0){
if(DEBUG != false)
System.out.prin tln("Converting Word:"+word);
uniWord = convertWord(wor d);
if(DEBUG!=false )
System.out.prin tln("\nConverte d Word: "+uniWord);
uniLine += uniWord;
word="";
uniWord="";
//System.out.prin tln("dinesh:"+l inechar[i]);
}
uniLine += linechar[i];
}
else
{
word += linechar[i];
if(DEBUG)
System.out.prin tln("Current Word:"+word);
}
// System.out.prin tln("yogesh:"+l inechar[i]);
}
if(word.length( )!=0){
if(DEBUG)
System.out.prin tln("Converting Word:"+word);
uniWord = convertWord(wor d);
if(DEBUG)
System.out.prin tln("\nConverte d Word: "+uniWord); ;
uniLine += uniWord;
word="";
uniWord="";
}
if(DEBUG)
System.out.prin tln("Returning from convertLine: "+uniLine);
return uniLine;
}
public static String convertWord(Str ing word){
CusResult objCus = new CusResult();
char Charword[]=word.toCharArr ay();
String akshar="";
String uniWord="";
String cached_result=" ";
int len = word.length();
int i,bound_result= 0;
int flag=0;
// mitr lower_bound,upp er_bound,itr;->
String lower_bound= new String("");
String upper_bound= new String("");
if(DEBUG)
System.out.prin tln("Input Word: ["+word+"]");
// lower_bound=tm. firstEntry().to String();
// upper_bound=tm. lastEntry().toS tring();
for(i=0;i<len;i ++){
if(flag==0){ //-->if (flag==0 && word[i]){
akshar += Charword[i];
if(DEBUG) {
System.out.prin tln("\nreading "+Charword[i]);
}
}
if(DEBUG)
System.out.prin tln("\ncalling lower bound with "+akshar);
//bound_result = custom_bounds(a kshar,lower_bou nd,upper_bound) ;
objCus = custom_bounds(a kshar,lower_bou nd,upper_bound) ;
flag=0;
bound_result = objCus.getRet() ;
lower_bound = objCus.getLBoun d();
upper_bound = objCus.getUBoun d();
// Switch Remaining...
switch(bound_re sult){
case 0: //no entry found in mapping
if(DEBUG)
System.out.prin tln("No results found, Cache: "+cached_result );
if(cached_resul t.length()!=0){//there was some result before adding last char,
//use last found result (if single), and start afresh with last added char
uniWord += cached_result;
cached_result=" ";
// System.out.prin tln("Cahe Akasher1 :"+akshar);
int aks=akshar.leng th()-1;
akshar = akshar.substrin g(aks,aks+1);//->akshar = akshar[akshar.size()-1];
// System.out.prin tln("Cahe Akasher2 :"+akshar);
i--;
flag =1;
}
else{
//we have encountered a single char which doesnt start any mapping entry, append it as it to o/p and move ahead.
uniWord += akshar;
akshar="";
}
// lower_bound = tm.firstEntry() .toString();
//upper_bound = tm.lastEntry(). toString();
lower_bound = tm.firstKey().t oString();
upper_bound = tm.lastKey().to String();
break;
case 1: //exactly one result, cache it
// cached_result = lower_bound->second;//Remain
// System.out.prin tln("Exact Match :"+lower_bound) ;
//cached_result =mp.get(lbound1 G).toString();
cached_result = "";
cached_result =cached_result+ lower_bound;
break;
case 2: //multiple results
// if(lower_bound->first == akshar)
// cached_result = lower_bound->second;
// if(lbound1G == akshar) //exact match found in first entry, cache it
//cached_result = mp.get(lbound1G ).toString();
// System.out.prin tln("Mul Match Lower :"+lower_bou nd + " Mul Upper :" + upper_bound);
cached_result = lower_bound;
// System.out.prin tln("Lower Bound:"+lbound1 G+" AksharExact:"+a kshar+"cached_r esult:"+cached_ result);
break;
}
}
if(cached_resul t.length()>0)
uniWord += cached_result;
if(DEBUG)
System.out.prin tln("Returning from convertWord: "+uniWord);
return uniWord;
}
public static CusResult custom_bounds(S tring akshar,String lbound1,String ubound1){
CusResult objCusResult = new FileJavaNew5.Cu sResult();
Set set = tm.entrySet();
Iterator tit =set.iterator() ;
int alen=akshar.len gth();
//System.out.prin tln("Cus Akshar :"+akshar);
String tmp="";
String tmp1="";
int count=0;
while(tit.hasNe xt()){
Map.Entry me =(Map.Entry)tit .next();
tmp=me.getKey() .toString();
count++;
//System.out.prin tln("Sub String :" +tmp.substring( 0,alen));
if(tmp.length() >=alen) {
if(tmp.substrin g(0,alen).equal s(akshar)) {
tmp1=me.getValu e().toString();
break;
}
}
}
if(tit.hasNext( ) == false) // if no match found
//return 0;
return objCusResult;
lbound1 = tmp1;
NavigableMap nmp = tm.descendingMa p();
set = nmp.entrySet();
tit = set.iterator();
while(tit.hasNe xt()){
Map.Entry me =(Map.Entry)tit .next();
tmp=me.getKey() .toString();
if(tmp.length() >=alen) {
if(tmp.substrin g(0,alen).equal s(akshar)) {
tmp1=me.getValu e().toString();
break;
}
}
}
//System.out.prin tln("Upper = "+tmp1);
ubound1 = tmp1;
objCusResult.se tLBound(lbound1 );
objCusResult.se tUBound(ubound1 );
if(lbound1.equa ls(ubound1))
objCusResult.se tRet(1);
else
objCusResult.se tRet(2);
return objCusResult;
//objCusResult.se tRet(lbound1);
}
}