import java.io.*;
class runExtApp{
String arr[]=null;
public void runfunc(){
try{
Runtime.getRuntime().exec("oowriter -o /home/the exact path where your file exists");
}catch(IOException e){
System.out.println(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.dvbttyogesh) 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(String l) {
lbound = l;
}
public void setUBound(String 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.println("Fist give map file then Input file & OutputFile");
/* int i=args.length;
int j=3;
System.out.println(i);*/
try
{
/*if(args.length==3)
System.out.println(" ok");
else
System.out.println(" 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.hasMoreTokens())
{
String key= st.nextToken();
String val= st.nextToken();
tm.put(key,val);//Entered value in Map
}
}
//System.out.println("Asending Map :");
Set set = tm.entrySet();
Iterator tit =set.iterator();
while(tit.hasNext()){
Map.Entry me =(Map.Entry)tit.next();
//System.out.println(me.getKey()+":"+me.getValue());
}
fin.close();
}
catch (IOException e)
{
System.err.println ("Unable to read from file1");
System.exit(-1);
}
catch (ArrayIndexOutOfBoundsException e)
{
System.err.println ("it catch "+e);
System.exit(-1);
}
//mappingFileBegin();//call to vector map funct1ion
//System.out.println("Vec :"+vec.firstElement().toString());
//opening input file
FileInputStream finIn;
FileOutputStream finOut;
String line=null;
String uniLine=null;
try
{
finIn = new FileInputStream (ip);
DataInputStream in = new DataInputStream(finIn);
finOut = new FileOutputStream (op);
DataOutputStream out = new DataOutputStream(finOut);
while (in.available() !=0)
{
line = in.readLine();
uniLine=convertLine(line);
//out.writeChars(uniLine);
out.writeBytes(uniLine);
out.writeByte('\n');
//out.writeUTF(uniLine);
}
finIn.close();
finOut.close();
if(uniLine.length()>0)
{
//System.out.println("o/p File Contents:"+uniLine);
// outfptr<<uniLine<<endl;
}}
catch (IOException e)
{
System.err.println ("Unable to read from file 2");
System.exit(-1);
}
catch (ArrayIndexOutOfBoundsException e)
{
System.err.println ("yogesh"+e);
System.exit(-1);
}
}
public static boolean isdelim(char ch){
for(int i=0;i<delim.length();i++)
{
if(delim.charAt(i)==ch)
return true;
}
return false;
// return(delim.contains(ch));
}
public static String convertLine(String line)
{ char linechar[]=line.toCharArray();
int len = line.length();
String word="";
String uniWord="";
String uniLine="";
if(line.length()==0)
return "";
if(DEBUG)
{
System.out.println("Input Line:"+line);
System.out.println("Length Of Input Line:"+len);
}
for(int i=0;i<len;i++){
if(isdelim(linechar[i])){
if(word.length()!=0){
if(DEBUG != false)
System.out.println("Converting Word:"+word);
uniWord = convertWord(word);
if(DEBUG!=false)
System.out.println("\nConverted Word: "+uniWord);
uniLine += uniWord;
word="";
uniWord="";
//System.out.println("dinesh:"+linechar[i]);
}
uniLine += linechar[i];
}
else
{
word += linechar[i];
if(DEBUG)
System.out.println("Current Word:"+word);
}
// System.out.println("yogesh:"+linechar[i]);
}
if(word.length()!=0){
if(DEBUG)
System.out.println("Converting Word:"+word);
uniWord = convertWord(word);
if(DEBUG)
System.out.println("\nConverted Word: "+uniWord);;
uniLine += uniWord;
word="";
uniWord="";
}
if(DEBUG)
System.out.println("Returning from convertLine: "+uniLine);
return uniLine;
}
public static String convertWord(String word){
CusResult objCus = new CusResult();
char Charword[]=word.toCharArray();
String akshar="";
String uniWord="";
String cached_result="";
int len = word.length();
int i,bound_result=0;
int flag=0;
// mitr lower_bound,upper_bound,itr;->
String lower_bound= new String("");
String upper_bound= new String("");
if(DEBUG)
System.out.println("Input Word: ["+word+"]");
// lower_bound=tm.firstEntry().toString();
// upper_bound=tm.lastEntry().toString();
for(i=0;i<len;i++){
if(flag==0){ //-->if (flag==0 && word[i]){
akshar += Charword[i];
if(DEBUG) {
System.out.println("\nreading "+Charword[i]);
}
}
if(DEBUG)
System.out.println("\ncalling lower bound with "+akshar);
//bound_result = custom_bounds(akshar,lower_bound,upper_bound);
objCus = custom_bounds(akshar,lower_bound,upper_bound);
flag=0;
bound_result = objCus.getRet();
lower_bound = objCus.getLBound();
upper_bound = objCus.getUBound();
// Switch Remaining...
switch(bound_result){
case 0: //no entry found in mapping
if(DEBUG)
System.out.println("No results found, Cache: "+cached_result);
if(cached_result.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.println("Cahe Akasher1 :"+akshar);
int aks=akshar.length()-1;
akshar = akshar.substring(aks,aks+1);//->akshar = akshar[akshar.size()-1];
// System.out.println("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().toString();
upper_bound = tm.lastKey().toString();
break;
case 1: //exactly one result, cache it
// cached_result = lower_bound->second;//Remain
// System.out.println("Exact Match :"+lower_bound);
//cached_result =mp.get(lbound1G).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.println("Mul Match Lower :"+lower_bound + " Mul Upper :" + upper_bound);
cached_result = lower_bound;
// System.out.println("Lower Bound:"+lbound1G+" AksharExact:"+akshar+"cached_result:"+cached_resul t);
break;
}
}
if(cached_result.length()>0)
uniWord += cached_result;
if(DEBUG)
System.out.println("Returning from convertWord: "+uniWord);
return uniWord;
}
public static CusResult custom_bounds(String akshar,String lbound1,String ubound1){
CusResult objCusResult = new FileJavaNew5.CusResult();
Set set = tm.entrySet();
Iterator tit =set.iterator();
int alen=akshar.length();
//System.out.println("Cus Akshar :"+akshar);
String tmp="";
String tmp1="";
int count=0;
while(tit.hasNext()){
Map.Entry me =(Map.Entry)tit.next();
tmp=me.getKey().toString();
count++;
//System.out.println("Sub String :" +tmp.substring(0,alen));
if(tmp.length()>=alen) {
if(tmp.substring(0,alen).equals(akshar)) {
tmp1=me.getValue().toString();
break;
}
}
}
if(tit.hasNext() == false) // if no match found
//return 0;
return objCusResult;
lbound1 = tmp1;
NavigableMap nmp = tm.descendingMap();
set = nmp.entrySet();
tit = set.iterator();
while(tit.hasNext()){
Map.Entry me =(Map.Entry)tit.next();
tmp=me.getKey().toString();
if(tmp.length()>=alen) {
if(tmp.substring(0,alen).equals(akshar)) {
tmp1=me.getValue().toString();
break;
}
}
}
//System.out.println("Upper = "+tmp1);
ubound1 = tmp1;
objCusResult.setLBound(lbound1);
objCusResult.setUBound(ubound1);
if(lbound1.equals(ubound1))
objCusResult.setRet(1);
else
objCusResult.setRet(2);
return objCusResult;
//objCusResult.setRet(lbound1);
}
}