LRAW to java binary

LRAW have length 1024
FunctionName : YEMM_ATTACHMENT
COL_NAME DATA_TYPE LENGTH
FILE_NAME : CHAR 200
TLINENO: CHAR 4
CONTE: LRAW 1024
in java i can just using this
byte[] attachfile= file.getBytes();
if a file is bigger than 1024 , how do i store it and pass it to JCO..
do i have to pass line by line of binary code ??
JCO.Table inputAttach=function.getTableParameterList().getTable("SOBATTH");
ByteArrayOutputStream byteBuffer=new ByteArrayOutputStream();
if(blnAttach.equalsIgnoreCase("x")==true){            
if(inputAttach.getNumRows()>0){
int lineno=Integer.parseInt(inputAttach.getString("TLINENO"));
for(int k=0;k<lineno;k++){
fileName=inputAttach.getString("FILE_NAME");
file=inputAttach.getByteArray("ATTACHMENT");
ByteBuffer.write(file);
OutMailDetailsBean outMailDet=new OutMailDetailsBean();
outMailDet.setAttachment(ByteBuffer.toByteArray()); 
outMailDet.setAttachmentId(getAttachmentId());
outMailDet.setAttachmentName(fileName);
outMailDet.setEmailId(emailId);
beanList2.add(outMailDet);            
1) while converting the file ...i download it and open it....
when open, i always get file corrupted , although the file size is same as the original file
any idea ?
ABAP LRAW to java binary
2) This is printed from ABAP
how to i print the same thing in java and do a comparison i mean the binary code
Row MANDT FILE_NAME TLINENO CONTE
1 dsn.jar 1 504B0304140008000800A6419334000000000000000000000000090004004D4554412D494E462FFECA00000300504B0708000000000200000000000000504B0304140008000800A6419334000000000000000000000000140000004D4554412D494E462F4D414E49464553542E4D46858F3D0BC23014456703F90F01170B266
2 dsn.jar 2 E86A8F26B3D4982B3A3127AFEDF45E51B06E5E3B9375FEDF19DCB5464FD6151A2583C135098AD10E1A9DA98BFF60B69871DC90C619CB8A4BD13CBE56A736D88944A3B0F1443EE9E8D9ACC2D66514A68B4E230C1D2ED70A7D0A136B8B69229E4D470BC54C99ADE8709184DC66C5E764794A6658381D159CA3293B331F2D53E9B
3 dsn.jar 3 75BCE6C88334E5E173D055EC3D492C2765EB89785CCA756C0B45AEBA2135975912E1D8B2BF5D14075E67C95DC036BC41DB6F22828BBCFD2E0E578AE5051A700B4B4D86BF4037F31BBE896E1685B5846E298AAF89456FE43A7A98CD5ECFBE457488A99EDD55D2731ED5E31A7FE7D6BF966D0FD12AF8366DC2DB68E58B7323DF8
4 dsn.jar 4 FEECA515578654EC529CC3ADB0B985F088F433187BE9B10E923F07F46FFBBA9857BE91F90B504B0708A366CF5960020000B1040000504B03041400080008009B41933400000000000000000000000026000000636F6D2F73756E2F6D61696C2F64736E2F4D756C7469706172745265706F72742E636C617373AD5769705B571
5 dsn.jar 5 8286A5D14CDE3986F7CAE58CF75C3A95F096B6A850ED095050C570623B957B68A94DF6DEBDFF8D314BD1BBB914AB19F7DC54E082A571A1161A89A793D5B9EFE6614225C3099521A898D54565791D38B554A184E58164B66C558489B9F3DC8F9B44F0591F8C56375C0DF3C93085FAF9F2437217CF33CBC38B946219A98591B8E
6 dsn.jar 6 348F63AF5416B9F0551C40E779FC59791EB7F0DC57E5197FCD9E872BD8F243CBF43C647A76508BDA55D4CBB3EFAE3534E8814EC840557D2EC6A9C3293489D3681793555117CAF8D88A7C462DF8DC5F91498ACFDBB0F86F504B0708F2B9A927DE070000F6110000504B03041400080008009B419334000000000000000000000
7 dsn.jar 7 E8FD097D2F49986182D63E7A3D922222B40B0C4E622A341B27AA30AB447E457FB633F50A7D998323CD00F21AAD69E8E4A8D098A6BBB0372864270E71EA39BA539387183860072D9073E8C13C06B0482F6D548186E94FD31D9ADA209A909BAA40CD4EFC8C4186324E1FAC56309CAD60245BC61975F410EF90F5B3743BC4B932C
8 dsn.jar 8 A6A07E617A23BAD2F324ED965B7B20996A229CDA8356FC1991D78899D197D08BBF20F21C619298474CA3898F7EC3F00B326648D073986E78E01442380D8B56AA96DE82B00992AAB046E80FC48A83A95F319C6F743D8394B3F49C21CFC0E302C155F1C6946D7A1723CF104D9DD9C56883357A52CEE308AE61140B24251AB7039
9 dsn.jar 9 CCCBFBF840C1719C50F00D9C10D0446D10A23608711B84A80D42E56D20E2F70A3EC41FD8D44702EE74B26D333B8C14A112E8F5F9C40C1D29A136AC8DE9C399714228A0A5C01488510A2DDA0A94DB0F07142C609197AB0AAEB1E37FE4E524BE29C05FB0A617AAE0A82DC770FF24A0B968782895D2126AAACF4C6426A9E64AD0B
10 dsn.jar 10 2CBDCDE169E23B8F67CAB21025BD4E7C0E124DA49DCF3B6EA2EA02063B6EA02AECF2BBBAB2D8338F9EB0DBEFCEE2AEB0C7EFB9893A4ABADF730375ABA539DA4B3962A67C92164953CB45DC5FCA13241E2A9C2CDAE8C5DBCE0B15918FFE29BB64CA979315C22E21ECE6C26AE4747447BBFC14A050D83D8F9AB087F3C3DF4DAB8
11 dsn.jar 11 34D4628588B303000076070000270000000000000000000000000014190000636F6D2F73756E2F6D61696C2F64736E2F6D756C7469706172745F7265706F72742E636C617373504B010214001400080008009B419334A01611112F0800001F10000029000000000000000000000000001C1D0000636F6D2F73756E2F6D61696
Message was edited by:
yzme yzme>

Hi yzme
http://www.apentia-forum.de/viewtopic.php?t=1962&sid=9ac1506bdb153c14edaf891300bfde25
Hope if answers to your question.
Regards
Divya

Similar Messages

  • Convert LRAW to java binary

    this question should be asked in ABAP session,
    nevertheless, because no one answer at that section,
    LRAW have length 1024
    FunctionName : YEMM_ATTACHMENT
    COL_NAME DATA_TYPE LENGTH
    FILE_NAME : CHAR 200
    TLINENO: CHAR 4
    CONTE: LRAW 1024
    in java i can just using this
    byte[] attachfile= file.getBytes();
    if a file is bigger than 1024 , how do i store it and pass it to JCO..
    do i have to pass line by line of binary code ??
    JCO.Table inputAttach=function.getTableParameterList().getTable("SOBATTH");
    ByteArrayOutputStream byteBuffer=new ByteArrayOutputStream();
    if(blnAttach.equalsIgnoreCase("x")==true){            
    if(inputAttach.getNumRows()>0){
    int lineno=Integer.parseInt(inputAttach.getString("TLINENO"));
    for(int k=0;k<lineno;k++){
    fileName=inputAttach.getString("FILE_NAME");
    file=inputAttach.getByteArray("ATTACHMENT");
    ByteBuffer.write(file);
    OutMailDetailsBean outMailDet=new OutMailDetailsBean();
    outMailDet.setAttachment(ByteBuffer.toByteArray()); 
    outMailDet.setAttachmentId(getAttachmentId());
    outMailDet.setAttachmentName(fileName);
    outMailDet.setEmailId(emailId);
    beanList2.add(outMailDet);            
    1) while converting the file ...i download it and open it....
    when open, i always get file corrupted , although the file size is same as the original file
    any idea ?
    ABAP LRAW to java binary
    2) This is printed from ABAP
    how to i print the same thing in java and do a comparison i mean the binary code
    Row MANDT FILE_NAME TLINENO CONTE
    1 dsn.jar 1 504B0304140008000800A6419334000000000000000000000000090004004D4554412D494E462FFECA00000300504B0708000000000200000000000000504B0304140008000800A6419334000000000000000000000000140000004D4554412D494E462F4D414E49464553542E4D46858F3D0BC23014456703F90F01170B266
    2 dsn.jar 2 E86A8F26B3D4982B3A3127AFEDF45E51B06E5E3B9375FEDF19DCB5464FD6151A2583C135098AD10E1A9DA98BFF60B69871DC90C619CB8A4BD13CBE56A736D88944A3B0F1443EE9E8D9ACC2D66514A68B4E230C1D2ED70A7D0A136B8B69229E4D470BC54C99ADE8709184DC66C5E764794A6658381D159CA3293B331F2D53E9B
    3 dsn.jar 3 75BCE6C88334E5E173D055EC3D492C2765EB89785CCA756C0B45AEBA2135975912E1D8B2BF5D14075E67C95DC036BC41DB6F22828BBCFD2E0E578AE5051A700B4B4D86BF4037F31BBE896E1685B5846E298AAF89456FE43A7A98CD5ECFBE457488A99EDD55D2731ED5E31A7FE7D6BF966D0FD12AF8366DC2DB68E58B7323DF8
    4 dsn.jar 4 FEECA515578654EC529CC3ADB0B985F088F433187BE9B10E923F07F46FFBBA9857BE91F90B504B0708A366CF5960020000B1040000504B03041400080008009B41933400000000000000000000000026000000636F6D2F73756E2F6D61696C2F64736E2F4D756C7469706172745265706F72742E636C617373AD5769705B571
    5 dsn.jar 5 8286A5D14CDE3986F7CAE58CF75C3A95F096B6A850ED095050C570623B957B68A94DF6DEBDFF8D314BD1BBB914AB19F7DC54E082A571A1161A89A793D5B9EFE6614225C3099521A898D54565791D38B554A184E58164B66C558489B9F3DC8F9B44F0591F8C56375C0DF3C93085FAF9F2437217CF33CBC38B946219A98591B8E
    6 dsn.jar 6 348F63AF5416B9F0551C40E779FC59791EB7F0DC57E5197FCD9E872BD8F243CBF43C647A76508BDA55D4CBB3EFAE3534E8814EC840557D2EC6A9C3293489D3681793555117CAF8D88A7C462DF8DC5F91498ACFDBB0F86F504B0708F2B9A927DE070000F6110000504B03041400080008009B419334000000000000000000000
    7 dsn.jar 7 E8FD097D2F49986182D63E7A3D922222B40B0C4E622A341B27AA30AB447E457FB633F50A7D998323CD00F21AAD69E8E4A8D098A6BBB0372864270E71EA39BA539387183860072D9073E8C13C06B0482F6D548186E94FD31D9ADA209A909BAA40CD4EFC8C4186324E1FAC56309CAD60245BC61975F410EF90F5B3743BC4B932C
    8 dsn.jar 8 A6A07E617A23BAD2F324ED965B7B20996A229CDA8356FC1991D78899D197D08BBF20F21C619298474CA3898F7EC3F00B326648D073986E78E01442380D8B56AA96DE82B00992AAB046E80FC48A83A95F319C6F743D8394B3F49C21CFC0E302C155F1C6946D7A1723CF104D9DD9C56883357A52CEE308AE61140B24251AB7039
    9 dsn.jar 9 CCCBFBF840C1719C50F00D9C10D0446D10A23608711B84A80D42E56D20E2F70A3EC41FD8D44702EE74B26D333B8C14A112E8F5F9C40C1D29A136AC8DE9C399714228A0A5C01488510A2DDA0A94DB0F07142C609197AB0AAEB1E37FE4E524BE29C05FB0A617AAE0A82DC770FF24A0B968782895D2126AAACF4C6426A9E64AD0B
    10 dsn.jar 10 2CBDCDE169E23B8F67CAB21025BD4E7C0E124DA49DCF3B6EA2EA02063B6EA02AECF2BBBAB2D8338F9EB0DBEFCEE2AEB0C7EFB9893A4ABADF730375ABA539DA4B3962A67C92164953CB45DC5FCA13241E2A9C2CDAE8C5DBCE0B15918FFE29BB64CA979315C22E21ECE6C26AE4747447BBFC14A050D83D8F9AB087F3C3DF4DAB8
    11 dsn.jar 11 34D4628588B303000076070000270000000000000000000000000014190000636F6D2F73756E2F6D61696C2F64736E2F6D756C7469706172745F7265706F72742E636C617373504B010214001400080008009B419334A01611112F0800001F10000029000000000000000000000000001C1D0000636F6D2F73756E2F6D61696
    Message was edited by:
            yzme yzme

    Hi yzme
    http://www.apentia-forum.de/viewtopic.php?t=1962&sid=9ac1506bdb153c14edaf891300bfde25
    Hope if answers to your question.
    Regards
    Divya

  • When instructed "the java binary in your path"

    please help
    when Im instructed with the following:
    a JDK or JRE 1.0+ (see www.javasoft.com) installed and the java binary in your PATH
    my operating system is windows server 2000
    how do i set the path to to the java binary, Is the java binary. Is the java binary the bin folder, if so i have two of those, one directly under the jdk folder and one under jre folder.
    Do i use autoexecute.bat, if so how.
    thank you for any help rendered.
    Yaary

    Oh oh.
    Java uses the sys var CLASSPATH to look for - well - java classes.
    For that reason, CLASSPATH should always include ".;<yourJavaDir>\jre\lib\rt.jar" or ".;<yourJavaDir>\j2re1.4.x\lib\rt.jar". This ensures that Java can find the classes that come with the distribution (i.e. everything in rt.jar) and all classes in the directory from which you invoke Java or Javac.
    Now, the "<yourJavaDir>\jdk1.x.x\bin" thingie belongs into your PATH variable - that's the var your system uses to look for executables, i.e. java or javac.
    Regards, Thomas

  • How to read non-java binary file?

    Hello Team,
    I have problem to read non-java binary file.
    Let me explain.... I have one binary file created in vc++ having fix structure. Structure of file is like String,int,int,int.
    Now I have to read this file in my java application. I am failed to identify length of String value of Structure in java.
    Can any body help me to solve this problem?
    Thanks in advance.
    - Pathik

    Thanks for guide me,
    I have try using 0x00. And its working.
    Now I have another problem:
    in file.ext , I have written one record having structure string,int and int.
    I have enter data as "HelloWorld", 100 and 111.
    To read first record from file file.ext, following code I am using:
    try
         FileInputStream fis = new FileInputStream("file.ext");
         DataInputStream in = new DataInputStream(fis);
         char ch;
         while((ch=(char)in.readByte()) != 0x00)
              System.out.print(ch+"");
    System.out.println();
         System.out.println("Integer 1 --> " + in.readInt());
         System.out.println("Integer 2 --> " + in.readInt());
         in.close();
         fis.close();
    catch(Exception ex)
         System.out.println(ex.toString());
    And I am getting following output:
    HelloWorld
    Integer 1 --> 0
    Integer 2 --> 0
    File file.ext is created in vc++
    I am not getting integer data. Plz guide me for this problem.
    Thanks in advance
    - Pathik

  • Extend Domain to include BPM -- Enterprise manager crashes Java binary

    Hello,
    I thought I would share a rather puzzling issue.  I have been working with a Soa Suite Domain for quite some time now, and have it configured with a java email servers, JMS, Db Adapters, and I wanted to extend this domain so I backed it up and extended it to include BPM.  Later when opening EM, I would suddenly get a message saying that the Java SE Binary had stopped working.
    There are very few mentions on the net for weblogic, this one being the only one I could find JAVA (TM) Platform SE Binary Stopped Working on SOA Enterprise manager
    In my case, it turns out that I had an email server that was using one version of java, while the domain was working on the java version in the installation directory.  I went to the control panel, system, environmental variables and took the path of the java that the email server was using, and entered in the java version of the weblogic domain.  No problems so far....
    Stuart

    Looks like you have conflict with your java home and you are running 2 different JREs. Keep the latest and try launching EM console again and post the exception if you get any.
    Thanks,
    Vijay

  • Java binary search and insert

    I'm currently writing a program which is an appointment book. I currently have 4 classes and at the minute it can sort the array and print it out. I'm stuck at binary search and inserting a new appointment record. I will include the classes which i have got.
    Appointment
       import java.util.*;
       import java.io.*;
       import java.util.Scanner;
        class Appointment implements Comparable
          private String description;
          private int day;
          private int month;
          private int year;
          private String startTime;
          private String endTime;
          protected static Scanner keyboard = new Scanner(System.in);     
           public Appointment()
             description = "";
             day = 0;
             month = 0;;
             year = 0;;
             startTime = "";
             endTime = "";
           public Appointment(String appDesc, int appDay, int appMonth, int appYear, String appStartTime, String appEndTime)
             description = appDesc;
             day = appDay;
             month = appMonth;
             year = appYear;
             startTime = appStartTime;
             endTime = appEndTime;
           public void display()      
             System.out.print("  Description: " + description);
             System.out.print(", Date: " + day + "/" +month+ "/" +year);
             System.out.println(", Start Time: " + startTime);
             System.out.println(", End Time: " + endTime);
           public void setDay(int day)
          { this.day = day; }
           public int getDay()     
             return day; }
           public void setMonth(int month)
          { this.month = month; }
           public int getMonth()     
             return month; }
           public void setYear(int year)
          { this.year = year; }
           public int getYear()
             return year; }
           public int compareTo(Object obj)
             if (obj instanceof Appointment)
                Appointment appt = (Appointment) obj;
                if (this.day > appt.getDay())
                   return 1;
                else if (this.day < appt.getDay());
                return -1;
             return 0;
           public String toString() {
             StringBuffer buffer = new StringBuffer();
             buffer.append("Description: " + description);
             buffer.append(", Date: " + day + "/" +month+ "/" +year);
             buffer.append(", Start Time: " + startTime);
             buffer.append(", End Time: " + endTime);
             return buffer.toString();
           public void read(){
             System.out.print("Description : ");String descIn=keyboard.next();
             System.out.print("Day : ");int dayIn=keyboard.nextInt();
             System.out.print("Month : ");int monthIn=keyboard.nextInt();
             System.out.print("Year : ");int yearIn=keyboard.nextInt();
             System.out.print("Start Time : ");String startIn=keyboard.next();
             System.out.print("End Time : ");String endIn=keyboard.next();
             boolean goodInput = false;
             do{          
                try{
                   setDay(dayIn);
                   setMonth(monthIn);
                   setYear(yearIn);
                   goodInput = true;
                    catch(IllegalArgumentException e){
                      System.out.println("INVALID ARGUMENT PASSED FOR day or month or year");
                      System.out.println(e);
                      System.out.print("RE-ENTER VALID ARGUMENT FOR DAY : ");dayIn=keyboard.nextInt();
                      System.out.print("RE-ENTER VALID ARGUMENT FOR MONTH : ");monthIn=keyboard.nextInt();
                      System.out.print("RE-ENTER VALID ARGUMENT FOR YEAR : ");yearIn=keyboard.nextInt();                                        
             }while(!goodInput);
       }

    Array
    import java.util.*;
    class Array
         private Appointment[] app;
         private int nElems;
         Appointment tempApp;
         public Array(int max)
              app = new Appointment[max];
              nElems = 0;
         public Array(String desc, int day, int month, int year, String sTime, String eTime)
              app = new Appointment[100];
              nElems = 0;
       public int size()
          { return nElems; }
         void add(){
              Appointment appointmentToAdd = new Appointment();
              // Read its details
              appointmentToAdd.read();
              // And add it to the studentList
              //app[nElems].add(appointmentToAdd);
         public void add(String desc, int day, int month, int year, String sTime, String eTime)
            app[nElems] = new Appointment(desc, day, month, year, sTime, eTime);
            nElems++;             // increment size
              Appointment appointmentToAdd = new Appointment(desc, day, month, year, sTime, eTime);
              // And add it to the studentList
              //app[nElems].add(appointmentToAdd);
          public void insert(Appointment tempApp) {
        int j;
        for (j = 0; j < nElems; j++)
          // find where it goes
          if (app[j] > tempApp) // (linear search)
            break;
        for (int k = nElems; k > j; k--)
          // move bigger ones up
          app[k] = app[k - 1];
        app[j] = tempApp; // insert it
        nElems++; // increment size
       public void display()       // displays array contents
            for(int j=0; j<nElems; j++)    // for each element,
              app[j].display();     // display it
            System.out.println("");
         public void insertionSort()
       int in, out;
       for(out=1; out<nElems; out++) // out is dividing line
         Appointment temp = app[out];    // remove marked person
         in = out;          // start shifting at out
         while(in>0 &&        // until smaller one found,
            app[in-1].getMonth().compareTo(temp.getMonth())>0)
          app[in] = app[in-1];     // shift item to the right
          --in;          // go left one position
         app[in] = temp;        // insert marked item
         } // end for
       } // end insertionSort()
    }Menu
    import java.util.*;
    class Menu{
       private static Scanner keyboard = new Scanner(System.in);
       int option;
         Menu(){
            option=0;
         void display(){
              // Clear the screen
            System.out.println("\n1 Display");
              System.out.println("\n2 Insert");          
              System.out.println("3 Quit");          
         int readOption(){
            System.out.print("Enter Option [1|2|3] : ");
              option=keyboard.nextInt();
              return option;
    }Tester
       import java.util.*;
       import java.util.Arrays;
        class ObjectSortApp
           public static void main(String[] args)
                   int maxSize = 100;
                   Array arr;
                   arr = new Array(maxSize)
                   Appointment app1 = new Appointment("College Closed", 30, 4, 2009, "09:30", "05:30");;
                   Appointment app2 = new Appointment("Assignment Due", 25, 4, 2009, "09:30", "05:30");
             Appointment app3 = new Appointment("College Closed", 17, 4, 2009, "09:30", "05:30");
             Appointment app4 = new Appointment("Easter Break", 9, 4, 2009, "01:30", "05:30");
             Appointment app5 = new Appointment("College Opens", 15, 4, 2009, "09:30", "05:30");
             Appointment app6 = new Appointment("Assignment Due", 12, 4, 2009, "09:30", "05:30");
             Appointment app7 = new Appointment("Exams Begin", 11, 4, 2009, "09:30", "05:30");
                //To sort them we create an array which is passed to the Arrays.sort()
            //method.
            Appointment[] appArray = new Appointment[] {app1, app2, app3, app4, app5, app6, app7};
             System.out.println("Before sorting:");
            //Print out the unsorted array
            for (Appointment app : appArray)
                System.out.println(app.toString()); 
                Arrays.sort(appArray);
             //arr.insertionSort();      // insertion-sort them
             System.out.println("\n\nAfter sorting:");               
            //Print out the sorted array
            for (Appointment app : appArray)
                System.out.println(app.toString());
              Menu appMenu = new Menu();
              int chosenOption;
              do{
                 appMenu.display();
                   chosenOption=appMenu.readOption();
                   for (Appointment app : appArray)
                   switch(chosenOption){
                      case 1 : app.display(); break;
                        case 2 : arr.add(); break;
                        default:;
              }while(chosenOption != 3);    
          } // end main()
       } // end class ObjectSortApp

  • Can the java binary edited or translated to assembly?

    Hya,
    I was wondering how can i modificate a java program, after it has been compiled /binary/ or is there any way to translate it to assembly /a programming language/ then modificate it and reassemble it?
    Thanks

    After compiling a program say A.java
    You can see byte codes in assembly form
    by typing javap -c A.java
    This is similar to assembly program ,
    JVM executes this code which in in class file

  • Understanding Java Binary Incompatibility

    Hi folks,
    I'm just reading up about binary imcompatibility for a software engineering exam and having a hard time understanding the notes. Is anyone able to provide an understandable definition. I understand that the problem comes from having different classes at compile time than at runtime, but I'm trying to understand why this affects Java and not other languages, such as C.
    any input is much appreciated

    the simplest example I can think of is when a class changes its interface between versions. so you have
    1) MyClass.java is compiled to MyClass.class with a public method a()
    2) Client.java is compiled to Client.class that calls method a()
    3) MyClass.java is recompiled without Client.java present, having removed a() and replaced it by b()
    4) Client.class is run, the new MyClass.class is loaded and the JVM detects that a() is not found in MyClass.class's definition. This is not necessarily reported until Client attempts to call a()
    http://java.sun.com/docs/books/jls/second_edition/html/binaryComp.doc.html#44952
    asjf

  • Java Binary Search and sorting in Java

    My program is suppose to search news articles and alphabetize all the words article individually of the text file. Right now the program alphabetizes all the words of the articles including the numbers. The text file will be located below the code. So basically i need to know how to alphabetize every articles words individually.
    //This program reads an input line from the reader put the worda into an array with a count and increases
    //the count each time a word is repeated. It then sorts the words alphabetically in the array and
    //then prints out the array. There are 4 different articles like this one in the text file
    <ID>58</ID>
    <BODY>Assets of money market mutual funds
    increased 720.4 mln dlrs in the week ended yesterday to 236.90
    billion dlrs, the Investment Company Institute said.
        Assets of 91 institutional funds rose 356 mln dlrs to 66.19
    billion dlrs, 198 general purpose funds rose 212.5 mln dlrs to
    62.94 billion dlrs and 92 broker-dealer funds rose 151.9 mln
    dlrs to 107.77 billion dlrs.
    </BODY>
    import java.util.StringTokenizer;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    public class WordsFrequency
       public static void main(String[] args)
          // Initializations
          FileReader reader = null;
          FileWriter writer = null;
          // Open input and output files
          try
              reader = new FileReader("Reuters00.txt");
              writer = new FileWriter("WordsReport.txt");
          catch(FileNotFoundException e)
             System.err.println("Cannot find input file");
             System.exit(1);
          catch(IOException e)
           System.err.println("Cannot open input/output file");
           System.exit(2);
          // Set up to read a line and write a line
          BufferedReader in = new BufferedReader(reader);
          PrintWriter out = new PrintWriter(writer);
          out.println("Copied file is: Words followed by frequency");
          int count = 0;
           wordCount[] wordsArray = new wordCount[100000];
          boolean done = false;
          while(!done)
             String inputLine;
             try
                  inputLine= in.readLine();
             catch(IOException e)
                System.err.println("Problem reading input, program terminates. " );
                inputLine = null;
             if (inputLine == null)
               done = true;
         sortbyWords(wordsArray,count);
               for(int i = 0; i < count;i++)
                out.println(wordsArray.toString());
    else
                   StringTokenizer tokenizer = new StringTokenizer(inputLine);
              while(tokenizer.hasMoreTokens())
                   String token = tokenizer.nextToken();
                        int lengthofString = token.length();
                        char ch = token.charAt(lengthofString-1);
                        if(ch == '.' || ch == ',' || ch == '!' || ch == '?' || ch == ';')
                   token = token.substring(0,lengthofString-1);
    wordCount wordAndCount= new wordCount(token);
                        boolean skip = false;
                        for(int i = 0; i < count; i++)
                        if(token.equalsIgnoreCase(wordsArray[i].getWord()))
                             skip = true;
                             wordsArray[i].increaseFrequency();
                        if(skip == false)
                                  wordsArray[count] = wordAndCount;
                             count++;
    // Close files
    try
    in.close();
    catch(IOException e)
    System.err.println("Error closing file.");
    finally
    out.close();
         public static void sortbyWords(wordCount [] wArray, int size)
         wordCount temp;
         for (int j = 0; j < size-1; j++)
         for (int i = 0; i < size-1; i++)
         if (wArray[i].getWord().compareToIgnoreCase(wArray[i+1].getWord()) > 0)
              temp = wArray[i];
              wArray[i] = wArray[i + 1];
              wArray[i+1] = temp;
    Edited by: IronManNY on Sep 25, 2008 3:24 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    IronManNY wrote:
    My program is suppose to search news articles and alphabetize all the words article individually of the text file. Right now the program alphabetizes all the words of the articles including the numbers. The text file will be located below the code. So basically i need to know how to alphabetize every articles words individually.You want to strip out the numbers?

  • Java binary to decimal?

    how do i convert a binary number to a decimal number using Jbuttons and Jlabel for the output? the binary number should be entered into a Jtextfield
    thank you

    rpgangsta wrote:
    how do i convert a binary number to a decimal number using Jbuttons and Jlabel for the output? the binary number should be entered into a Jtextfield
    thank youThe user sees a text. You read that text, convert it into an internal representation, manipulate it, and then show the result to the user again as a text.
    You have: String (read from user) -> internal data -> (manipulation of data) - > internal data - > String (shown to user).

  • BINARY FILE- LRAW problem

    this question should be asked in ABAP session,
    nevertheless, because no one answer at that section,
    LRAW have length 1024 
    FunctionName : YEMM_ATTACHMENT
    COL_NAME    DATA_TYPE   LENGTH
    FILE_NAME :     CHAR            200
    TLINENO:          CHAR               4
    CONTE:            LRAW           1024
    in java i can just using this
    byte[]  attachfile= file.getBytes();
    if a file is bigger than 1024 , how do i store it and pass it to JCO..
    do i have to pass line by line of binary code ??
    JCO.Table inputAttach=function.getTableParameterList().getTable("SOBATTH");
    byte[] file=new byte[10*1024];
    if(blnAttach.equalsIgnoreCase("x")==true){            
    if(inputAttach.getNumRows()>0){
    int lineno=Integer.parseInt(inputAttach.getString("TLINENO"));
    for(int k=0;k<lineno;k++){
    fileName=inputAttach.getString("FILE_NAME");
    file=inputAttach.getByteArray("ATTACHMENT");
    //how do i concatenate the bytes that store in several lines
    OutMailDetailsBean outMailDet=new OutMailDetailsBean();
    outMailDet.setAttachment(file); 
    outMailDet.setAttachmentId(getAttachmentId());
    outMailDet.setAttachmentName(fileName);
    outMailDet.setEmailId(emailId);
    beanList2.add(outMailDet);            
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme

    1) while converting the file ...i download it and open it....
    when open, i always get file corrupted , although the file size is same as the original file
    any idea ?
    ABAP LRAW to java binary
    2) This is printed from ABAP
    how to i print the same thing in java and do a comparison  i mean the binary code
    Row     MANDT     FILE_NAME     TLINENO     CONTE
    1          dsn.jar     1     504B0304140008000800A6419334000000000000000000000000090004004D4554412D494E462FFECA00000300504B0708000000000200000000000000504B0304140008000800A6419334000000000000000000000000140000004D4554412D494E462F4D414E49464553542E4D46858F3D0BC23014456703F90F01170B266
    2          dsn.jar     2     E86A8F26B3D4982B3A3127AFEDF45E51B06E5E3B9375FEDF19DCB5464FD6151A2583C135098AD10E1A9DA98BFF60B69871DC90C619CB8A4BD13CBE56A736D88944A3B0F1443EE9E8D9ACC2D66514A68B4E230C1D2ED70A7D0A136B8B69229E4D470BC54C99ADE8709184DC66C5E764794A6658381D159CA3293B331F2D53E9B
    3          dsn.jar     3     75BCE6C88334E5E173D055EC3D492C2765EB89785CCA756C0B45AEBA2135975912E1D8B2BF5D14075E67C95DC036BC41DB6F22828BBCFD2E0E578AE5051A700B4B4D86BF4037F31BBE896E1685B5846E298AAF89456FE43A7A98CD5ECFBE457488A99EDD55D2731ED5E31A7FE7D6BF966D0FD12AF8366DC2DB68E58B7323DF8
    4          dsn.jar     4     FEECA515578654EC529CC3ADB0B985F088F433187BE9B10E923F07F46FFBBA9857BE91F90B504B0708A366CF5960020000B1040000504B03041400080008009B41933400000000000000000000000026000000636F6D2F73756E2F6D61696C2F64736E2F4D756C7469706172745265706F72742E636C617373AD5769705B571
    5          dsn.jar     5     8286A5D14CDE3986F7CAE58CF75C3A95F096B6A850ED095050C570623B957B68A94DF6DEBDFF8D314BD1BBB914AB19F7DC54E082A571A1161A89A793D5B9EFE6614225C3099521A898D54565791D38B554A184E58164B66C558489B9F3DC8F9B44F0591F8C56375C0DF3C93085FAF9F2437217CF33CBC38B946219A98591B8E
    6          dsn.jar     6     348F63AF5416B9F0551C40E779FC59791EB7F0DC57E5197FCD9E872BD8F243CBF43C647A76508BDA55D4CBB3EFAE3534E8814EC840557D2EC6A9C3293489D3681793555117CAF8D88A7C462DF8DC5F91498ACFDBB0F86F504B0708F2B9A927DE070000F6110000504B03041400080008009B419334000000000000000000000
    7          dsn.jar     7     E8FD097D2F49986182D63E7A3D922222B40B0C4E622A341B27AA30AB447E457FB633F50A7D998323CD00F21AAD69E8E4A8D098A6BBB0372864270E71EA39BA539387183860072D9073E8C13C06B0482F6D548186E94FD31D9ADA209A909BAA40CD4EFC8C4186324E1FAC56309CAD60245BC61975F410EF90F5B3743BC4B932C
    8          dsn.jar     8     A6A07E617A23BAD2F324ED965B7B20996A229CDA8356FC1991D78899D197D08BBF20F21C619298474CA3898F7EC3F00B326648D073986E78E01442380D8B56AA96DE82B00992AAB046E80FC48A83A95F319C6F743D8394B3F49C21CFC0E302C155F1C6946D7A1723CF104D9DD9C56883357A52CEE308AE61140B24251AB7039
    9          dsn.jar     9     CCCBFBF840C1719C50F00D9C10D0446D10A23608711B84A80D42E56D20E2F70A3EC41FD8D44702EE74B26D333B8C14A112E8F5F9C40C1D29A136AC8DE9C399714228A0A5C01488510A2DDA0A94DB0F07142C609197AB0AAEB1E37FE4E524BE29C05FB0A617AAE0A82DC770FF24A0B968782895D2126AAACF4C6426A9E64AD0B
    10          dsn.jar     10     2CBDCDE169E23B8F67CAB21025BD4E7C0E124DA49DCF3B6EA2EA02063B6EA02AECF2BBBAB2D8338F9EB0DBEFCEE2AEB0C7EFB9893A4ABADF730375ABA539DA4B3962A67C92164953CB45DC5FCA13241E2A9C2CDAE8C5DBCE0B15918FFE29BB64CA979315C22E21ECE6C26AE4747447BBFC14A050D83D8F9AB087F3C3DF4DAB8
    11          dsn.jar     11     34D4628588B303000076070000270000000000000000000000000014190000636F6D2F73756E2F6D61696C2F64736E2F6D756C7469706172745F7265706F72742E636C617373504B010214001400080008009B419334A01611112F0800001F10000029000000000000000000000000001C1D0000636F6D2F73756E2F6D61696
    anyone can help me
    Message was edited by:
            yzme yzme

  • Creating Binary Files in Java

    Does anyone know how to create a binary file in Java.
    in C i can do an fopen("filename" , "rb") i cannot find a equivalent java binary file stream.
    Thanks

    The following code is part of my FileIO applet. This method allows the user to download any file from my server and save it on his/her disk, the download is accomplished by doing a byte-read and byte-write (byte mover as I'd call it). This example illustrates how you can read and write binary files in Java:
       public void aok_DownLoad(String inputFile, String outputFile) {
          try {
             URL url=new URL(inputFile);
             InputStream in;
             in=url.openStream();
             BufferedInputStream reader=new BufferedInputStream(in,4096);
             FileOutputStream out=new FileOutputStream(outputFile);
             BufferedOutputStream writer=new BufferedOutputStream(out,4096);
             byte[] buf=new byte[4096];
             int byteRead;
             while ((byteRead=reader.read(buf,0,4096))>=0) {writer.write(buf,0,byteRead);}
             reader.close();
             writer.flush();
             writer.close();
          catch (Throwable exception) {
             exception.printStackTrace();
       }V.V.
    PS: in this posting the code is posted in a different manner so that the > sign is not converted to & gt ; by the forum's software

  • Java threads on machines with hundreds of cores

    I don't know if this is the right forum, but I try anyway.
    My problem is with java on machines with many cores.
    I have some large shared memory machines with 500 cores.
    When a user run java programs on these machines java starts 300+ threads which to me seems way too much for the application as the same application runs faster on systems with less cores and memory and without creating 300+ threads.
    I have found information about how to limit memory usage, but I have not been able to find any information about how to limit the number of threads java creates nor what criteria java uses to determine how many threads should be created.
    In this context threads are the tasks reported under /proc/<PID of java binary>/task on a Linux system.
    Thanks
    John

    Hi,
    Thanks for the reply.
    We did some more testing and found that java on startup looks in /sys/devices/system/cpu/, which holds information about the 512 CPU's on the system.
    We then tried to lower number of allowed processes using ulimit -u 20 and got this error when running the program:
    # A fatal error has been detected by the Java Runtime Environment:
    # java.lang.OutOfMemoryError: Cannot create GC thread. Out of system resources.
    # Internal Error (gcTaskThread.cpp:38), pid=303212, tid=140353923254032
    # Error: Cannot create GC thread. Out of system resources.
    # JRE version: 6.0_21-b06
    # Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0-b16 mixed mode linux-amd64 )
    # An error report file with more information is saved as:
    # /net/panfsdb0/panfsvol1/simon/projects/cge/test/hs_err_pid303212.log
    # If you would like to submit a bug report, please visit:
    # http://java.sun.com/webapps/bugreport/crash.jsp
    Aborted
    Now a Google search for gcTaskThread revealed that it is the Garbage Collector that creates the many threads. Google also told us that the number of GC threads can be controlled by the JVM option -XX:ParallelGCThreads=<number_of_GC_threads> . Specifying 8 GC threads the program now runs with 18 threads. Specifying 4 GC threads the program runs with 14 threads.
    So it seems like the JVM by default creates as many Garbage Collectors threads as there are CPU's in the system.
    This is a very bad practice as on such systems where programs are run within cpusets with just a small subset of the system wide CPU's.
    Instead of searching /sys/devices/system/cpu/ for number of system wide CPU's JVM should read /dev/cpuset/<cpuset id>/cpus to see how many CPU's are actually available for the job.
    Thanks
    John
    Edited by: 886656 on Sep 22, 2011 2:13 AM

  • Run time java compiler

    Last year I researched oracle spatial technology and created prototype using oracle 9i, standalone oc4j. In order to start oc4j, i had to download java 1.4.2 from sun site. everything worked fine.
    Now I am expanding on the prototype on different machine but am using oracle 10g. I followed the same steps (installed 10g, oc4j, downloaded j2se 1.4.2 and installed). When I start oc4j by following command
    java -jar oc4j.jar, I get
    error message stating Error loading package at file:/E:/oracle_downloads/oc4j/j2ee/home/applications/admin_ejb.jar, javac.exe no
    t found under F:\oracle\product\10.1.0\db_1\jre\1.4.2, please use a valid jdk or
    specify the location of your java compiler in server.xml using the <java-compil
    er .../> tag.
    I am not sure how do I specify location of java compiler in server.xml file sysntactically. I do not not recall this step with oracle 9i.
    I edited server.xml and http-wev-site.xml as per instructions in my spatial class for mapviewer application but I need help on how to enter the location of java compiler file in server.xml file.
    Thank you

    You cannot use the JRE java to start oc4j. Must install a complete 1.4.2 J2SDK (not JRE) then use the java binary under its bin directory to start oc4j (not the one under jre/bin directory).
    lj

  • Read in a file and convert into Binary

    Hi there, i am new to java so plz give me a hand on this problem.
    I am suppose to read in a file(with whole bunch of different records), and what i need to do is convert the file into binary.....how do i do that??
    the original Q asked:
    Create a java program that will read the products file and write the products data into a java binary file. Adhere to good data typing conventions. That means, if a column in the input file is of type integer, then the data in that column should also be written to the output file in integer format. Same thing for String...
    Here is the code i have so far
    import java.io.*;
    class FileIO {
    /* Main method */
    public static void main(String[] args) throws IOException {
         FileReader file1 = new FileReader("test.txt");
         BufferedReader fileInput = new BufferedReader(file1);
         FileWriter file2 = new FileWriter("test1.txt");
         PrintWriter fileOutput = new PrintWriter(file2);
         String text;
         text = fileInput.readLine();
         //toBinaryString(text); <---i think there is something to do with the tobinary string but i am not sure
              System.out.println(text);
              fileOutput.println(text);
         // Close file
         fileInput.close();
         fileOutput.close();
    E-mail me directly if it's possible, thanks a lot~!!!!!

    Maybe not the answer the teacher is looking for, but I'd be highly tempted to point out that the file, regardless of what's in it, is already binary. Even if it's a text file, what do you think the characters are defined as? Bytes.

Maybe you are looking for