How to make code portable

Hi,
I have a question like how can one make the following java code portable on different enviroments. What are the parts of the code that are not portable and how to rewrite the code in more portable manner.
Here is the code.
import java.io.IOException;
import java.io.RandomAccessFile;
* Some not very portable Java code. This code obtains a letter from the user
* and gets a corresponding integer from a binary array stored in a file. The
* value "base" is the starting position for the array in the file. The method
* "readbyte" reads one byte from the file at a given position. This code is
* assumed to occur within method Main of a public Java class.
public class Portable {
     public static void main(String args[])throws IOException  {
          int letter, start, base=0, val;
          int inbuf[] = new int[50];
          byte inb;
          RandomAccessFile ra = new RandomAccessFile("abc.txt","rw");
          //DataInputStream dr = new DataInputStream(fr);
          System.out.print("Enter a letter between A and Z: ");
          letter = (int) System.in.read();
          if ((letter >= (int) 'a') && (letter <= (int) 'a' + 25)) {
               letter = letter - 32;
          if ((letter >= (int) 'A') && (letter <= (int) 'A' + 25)) {
               start = base + 4 * (letter - (int) 'A');
               val = 0;
               for (int pos = start; pos < start + 4; pos++) {
                    ra.seek(pos);
                    inb = ra.readByte();
                    val = (val << 8) + ra.readByte();
               System.out.println("The value stored at position " + letter
                         + " is " + val);
}Any help would be great.
Thanx.

I can't see any code which stores any data, but the byte order for an int can be different on different platforms, but that's more related to the format of the file.
Kaj

Similar Messages

  • How to make code standardization in oracle 10 in sql/pl-sql

    if any body helps to handle how to make code standaridazation in oracle 10g in sql/pl-sql.

    refer tis link and get download..
    http://www.itap.purdue.edu/ea/data/standards/plsql.cfm

  • How to make code immune to changes in (external) database names?

    I wonder if there is a way to make code in one database immune to changes in names of other databases that the code uses. Essentially, what I'm after is something like an alias but not for a specific object in a database but rather for a whole database,
    be it on the same server or any other place. Is something like this possible? I wouldn't like to use Linked Servers, bear in mind please... Thanks for any replies!
    Darek

    hi Darek,
    Have you considered using SSIS for your code?  When you use SSIS, you can use data sources which are referenced by the packages, and the underlying connections to databases/servers can be changed without affecting the code.  In fact, if you use
    configuration files it becomes as simple as changing one record in a table to change where your data sources are pointing. Here is a blog on using ssis package configurations to manage data sources.
    http://dataqueen.unlimitedviz.com/2012/02/creating-an-ssis-package-template-with-predefined-package-configurations/
    SSIS is a really powerful way to manage your ETL requirements.
    Martina White

  • How to make code in dreamweaver flow to the next line?

    The line lengths of my code are really really long. How do I make it automatically flow to the next line without causing it to actually be a new line? Just for viewing purposes. I don't like having to scroll all the way to the end of the line of code to add a close tag.

    Hi
    Right-click on the area next to the 'box' that has the page title, and select 'coding' to enable the coding toolbar, (appears on the l/h side of the code window) then select the word wrap icon, see image -
    PZ

  • How to make VI portable?

    I need to move a large VI from my computer to another in our company.
    The VI has a lot of subs that are not all in its llb. Is there a tool
    put all the Vis I need into one llb or something that makes it easier?
    Thanks

    Open your main VI. In the menu File, you'll find "Save with options". Choose "Development distribution". The main VI and all his subvis will be put together in a LLB.
    Have a nice week end.

  • How to make code work for previous versions

    Hello, i have written the code below using swing 1.4. I was wondering if anyone could help me by letting me know what to convert so i run run this on a machine with a lower java runtime (ie 1.22)
    What i am trying to do is have a tree with a list of files, and when u click on a node, the tree will expand, and send the node name accross to another frame. Help is most appreciated. Thanks
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.event.TreeSelectionEvent;
    import java.net.*;
    import java.applet.AppletContext;
    import java.util.Enumeration;
    public class SimpleTree extends JApplet  {
    JTree tree = new JTree();
      public void init() {
       new SimpleTree();
      public SimpleTree() {
    /*try {
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch(Exception e) {
          System.out.println("Error setting native LAF: " + e);
        Container content = getContentPane();
        Object[] hierarchy =
          {"WebSphere MQ",
            new Object[] { "400","400 Pstuff.htm",
         "400 PStuff.htm",
         "A406 - Pstfdfs.htm"}}
        DefaultMutableTreeNode root = processHierarchy(hierarchy);
        tree = new JTree(root);
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
             DefaultMutableTreeNode node = (DefaultMutableTreeNode)
             tree.getLastSelectedPathComponent();
             String stringname = tree.getLastSelectedPathComponent().toString();
             if (node == null) return;
             if (node.isLeaf()) {
                try {
                           getAppletContext().showDocument(new URL("http://mql3service.hursley.ibm.com/process/"+stringname), "viewer");
                  }catch(Exception f) {System.out.println("" + f); }   
        content.add(new JScrollPane(tree), BorderLayout.CENTER);
        setSize(500, 700);
        setVisible(true);
      public DefaultMutableTreeNode processHierarchy(Object[] hierarchy) {
        DefaultMutableTreeNode node =
          new DefaultMutableTreeNode(hierarchy[0]);
        DefaultMutableTreeNode child;
        for(int i=1; i<hierarchy.length; i++) {
          Object nodeSpecifier = hierarchy;
    if (nodeSpecifier instanceof Object[]) // Ie node with children
    child = processHierarchy((Object[])nodeSpecifier);
    else
    child = new DefaultMutableTreeNode(nodeSpecifier); // Ie Leaf
    node.add(child);
    return(node);
    public void Rupz(String random)
    TreePath path = null;
    TreeNode [] treenode = null ;      
    String strNode = random;
    DefaultMutableTreeNode root = (DefaultMutableTreeNode)tree.getModel().getRoot();
    Enumeration e = root.breadthFirstEnumeration();
    while(e.hasMoreElements())
    DefaultMutableTreeNode dftTmp = (DefaultMutableTreeNode)e.nextElement();
    if(dftTmp.toString().equals(strNode))
         treenode = dftTmp.getPath();
         path = new TreePath(treenode) ;
    try {
    getAppletContext().showDocument(new URL("http://mql3service.hursley.ibm.com/process/"+strNode), "viewer");
         }catch(Exception f) {
         System.out.println("" + f);           
    if(path != null)
         tree.setSelectionPath(path);
    repaint();
    public static void main(String [] args) {
    JFrame f = new JFrame("") ;
    Container contentPane = f.getContentPane();
    contentPane.setLayout(new FlowLayout());
    SimpleTree ta = new SimpleTree() ;
    ta.init() ;
    f.addWindowListener(new ExitListener());
    f.setSize(500,700);
    contentPane.add(ta,BorderLayout.CENTER);
    f.setVisible(true) ;

    hi!
    you can get lead selection in the action handler then inset your code for currentContextElement.
    wdContext.currentContextElement().getTableSorter().sort(wdEvent, wdContext.nodeXXX());
    thanks
    vishal

  • How to make VIP flag in transaction code fpp2 as non editable

    Hi everyone,
    Please guide me about:
    How to make VIP flag in T Code FPP2 as non editable only for some particular users?
    Is there any authorization object exists for this flag in FPP2 transaction?
    Actually there are many users who have authorization of transaction fpp2. But we want only some particular users should have authorization of making changes to this flag.
    Please guide with your valuable replies.
    Thanks and Regards

    Hi...MP Vashishth
    try to creat an Authorization Management ...  in customizing...
    Cross-Application Components --> SAP Business Partner --> Business Partner --> Basic Settings --> Authorization Management
    Creat an Grup..and others steps...!
    and when finish clic on Generate and Assin Authorization !!!
    I Hope it Help !
    regards
    Andre Frugulhetti
    Edited by: Andre Frugulhetti on Sep 22, 2009 9:38 PM
    Edited by: Andre Frugulhetti on Sep 22, 2009 9:39 PM

  • How to make all fields mandatory in sales order T- code VA01 initial screen

    Dear all,
    how to make all fields mandatory in sales order T- code VA01 initial screen itself
    The fields are
    Sales Organization
    Distribution Channel
    Division
    Sales Office
    Sales Group
    Regards,
    Amar Reddy

    Hi,
    You can use Transaction Variant to achieve this functionality.Please go through the following link which helps you in creating the same.
    [Link|http://wiki.sdn.sap.com/wiki/display/Snippets/TransactionVariant-AStepbyStepGuidefor+Creation]
    Regards,
    Phani Prasad

  • How to Make Project Code as Mandatory

    Hi ! I Need Project code as mandatory in Po's and Sales Order in Row Level. How to Make that one. Also i have a issue with approved PO's. If some PO got approved is there any option to make amendment and resend for again approval.
    Thanks and Regards
    Kamal

    Hi Kamal.......
    Try this below SP for making project Code Mandatory........
    For Sales Order:
    If @object_type='17' and @transaction_type='A'
    BEGIN
    If Exists (Select T0.DocEntry from ORDR T0 Inner Join RDR1 T1
    On T0.DocEntry=T1.DocEntry
    Where T1.Project Is Null
    And T0.DocEntry = @list_of_cols_val_tab_del)
    BEGIN
    Select @error = -1,
    @error_message = 'Please select Project'
    End
    End
    For Purchase Order:
    If @object_type='22' and @transaction_type='A'
    BEGIN
    If Exists (Select T0.DocEntry from OPOR T0 Inner Join POR1 T1
    On T0.DocEntry=T1.DocEntry
    Where T1.Project Is Null
    And T0.DocEntry = @list_of_cols_val_tab_del)
    BEGIN
    Select @error = -1,
    @error_message = 'Please select Project'
    End
    End
    If your PO is approved and you want to ammend it then your approver has to reject the PO first and it will come to you and then make edition and send it again......
    Regards,
    Rahul

  • I Want to make an app.. but i dont know how to write code or use Xcode... where I can begin?

    Hey!
         I just graduate from high school.. im gonna study Computer Enginnering. Im working for my family and they need an app that works like iBook. We have the eBooks and then they want me to do an app where they can sell the eBooks and read them. I have Xcode, but I dont know how to write codes or where to begin in all of this. I want to make the app first for iPad but if it can be for both iPad and iPhone better. I just want recommendation and help. Please and Thanks!! 

    hello i hope your having a good day but can you reply to me if you got the codes to make an app because i want to make an app too  thanks

  • How to make reason code compulsory while processing F-53

    Hi Boss,
    Can u plz. tell me How to make reason code compulsory while processing F-53. this is because I have defined differnet reason code and one is having blank text.
    Thanks
    S

    hi,
    Just check this one dont check previous one....
    goto TCODE OBC4 and then click on ur company FELD status variant and double click on field status group ....
    Then click on G067 RECONCILTION ACCOUNTS and then double clickn that in that and then click on payment transactions and then select REASON CODE AS REQUIRED.
    ur problem will solve...
    if useful assign points
    regards,
    santosh kumar

  • How to make the description field as mandatory in IW31 T.code

    Hi All,
    My requirement is make the Description field as mandatory in T.code: IW31
    That field is CAUFVD-KTEXT.
    How to make this field as mandatory,
    I tried with BADI: IWO1_SCREEN_MODIFY
    And some customer exists also (ZXWOCU04, ZXWOCU09) but unfortunately I couldnu2019t reach my functionality
    Can any please help me to reach out my functionality?
    Thanks and Regards,
    Rambabu.

    Dear Friend,
    go to spro - plant maintenance and customer service - maintenance and service processing - maintenance and service orders - define field selection for order header data(pm) -Field Selection for Order Header Data and Reference Object
    here keep CAUFVD-KTEXT is mandatory for your order types.
    Regards,
    pardhu

  • How to make tax codes in mm purchasing

    Dear Guru,
    1. How to make tax code for purchase of Raw materials with basic excise duty=14%, SECess=2%, HSEcess=1% and Additional Excise duty=4% as follows . If we consider basic prise=100 then
    BASIC                  =100
    BED    (14%)        =14
    SED     (2%)        =0.28----
    Sed=secondary Educational Cess
    HSECESS (1%)     =0.14
    SUB TOTAL        = 114.42
    AED (4%)           =4.56
    TOTAL             = 119
    For above all taxces(BED,SED,HSEcess,AED) , client gets 100% set off.
    Please tell me detail procedure.
    2.Do we need to assign (tax code)  them to any business area, as my system is giving an error at the time of saving in MIRO.
    3. What is the meaning of ticking ( check box tick) for calculate taxes under  basic tab in MIRO.

    Hi Nitin,
    Tax Set Off depends on the Account Key which you are using. Account Key in Tax Procedure will be defined by finance at SPRO - Financial Accounting - Financial Accounting Global Settings - Tax on Sales / Purchases -   Basic Settings - Check and Change settings for Tax Processing.
    Check the relevant condition type in the Tax Procedure (TAXINJ / TAXINN), and then check the account key of the procedure whether the Non Deductable indicator is set or not. you may take finance help for the same. Once it is done correctly then define the excise defaults for the relevant tax procedure at SPRO - Logistics General - Tax on Goods Movement - India - Basic Settings - Determination of Excise duty - Maintain Excise defaults
    Then create the tax code with the relevant condition types.
    You need to assign the Tax code to Company code if you use TAXINN procedure. No need for assignment of Tax code to Business Area
    Once you select the Check Box Calculate taxes in MIRO, then system calculates the Taxes based on the tax codes defined and also validates whether Part II Postings have been done or not also for the Excise relevant transactions
    Regards,
    Ramakrishna

  • Anyone knows how to make this code to netbeans??

    anyone knows how to make this code to netbeans?? i just want to convert it into netbeans... im not really advance with this software... anyway..just reply if you have any idea...or steps how to build it... etc.... thanks guys...
       import javax.swing.*;
       import javax.swing.table.*;
       import java.awt.*;
       import java.awt.event.*;
       import java.util.regex.*;
       public class FilterTable {
         public static void main(String args[]) {
           Runnable runner = new Runnable() {
             public void run() {
               JFrame frame = new JFrame("Sorting JTable");
               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               Object rows[][] = {
                 {"AMZN", "Amazon", 41.28},
                 {"EBAY", "eBay", 41.57},
                 {"GOOG", "Google", 388.33},
                 {"MSFT", "Microsoft", 26.56},
                 {"NOK", "Nokia Corp", 17.13},
                 {"ORCL", "Oracle Corp.", 12.52},
                 {"SUNW", "Sun Microsystems", 3.86},
                 {"TWX",  "Time Warner", 17.66},
                 {"VOD",  "Vodafone Group", 26.02},
                 {"YHOO", "Yahoo!", 37.69}
               Object columns[] = {"Symbol", "Name", "Price"};
               TableModel model =
                  new DefaultTableModel(rows, columns) {
                 public Class getColumnClass(int column) {
                   Class returnValue;
                   if ((column >= 0) && (column < getColumnCount())) {
                     returnValue = getValueAt(0, column).getClass();
                   } else {
                     returnValue = Object.class;
                   return returnValue;
               JTable table = new JTable(model);
               final TableRowSorter<TableModel> sorter =
                       new TableRowSorter<TableModel>(model);
               table.setRowSorter(sorter);
               JScrollPane pane = new JScrollPane(table);
               frame.add(pane, BorderLayout.CENTER);
               JPanel panel = new JPanel(new BorderLayout());
               JLabel label = new JLabel("Filter");
               panel.add(label, BorderLayout.WEST);
               final JTextField filterText =
                   new JTextField("SUN");
               panel.add(filterText, BorderLayout.CENTER);
               frame.add(panel, BorderLayout.NORTH);
               JButton button = new JButton("Filter");
               button.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                   String text = filterText.getText();
                   if (text.length() == 0) {
                     sorter.setRowFilter(null);
                   } else {
                     try {
                       sorter.setRowFilter(
                           RowFilter.regexFilter(text));
                     } catch (PatternSyntaxException pse) {
                       System.err.println("Bad regex pattern");
               frame.add(button, BorderLayout.SOUTH);
               frame.setSize(300, 250);
               frame.setVisible(true);
           EventQueue.invokeLater(runner);
       }

    its okay onmosh.....what we need to
    this...forum....is to have a good......relationship
    of programmers......and to start with .....we need to
    have a good attitude........right.....???.....no
    matter how good you are in programming but if you did
    not posses the right kind of attitude....everything
    is useless.....in the first place....all we
    want....is just to ask...some....help....but
    conflicts......but unluckily......we did not expect
    that there are members in here which......not
    good...to follow.....just as suggestion for those
    people not having the right kind of attidude...why
    can't you do in a very nice message sharing in a very
    nice....way....why we need to put some
    stupid....stuff...words.....can't you live with out
    ******* ****....its not.....lastly especially you
    have your children right now and people around...that
    somehow......idiolize...you even me....is one of
    them......but showing but attitude....is not
    good......tnx....hope you'll take it this....in the
    positive side.....be optimistic...guys....the
    world..is not yours....all of us will just past
    away....always..remember that one.....treasure..our
    stay in this....temporary home.....which...is
    world....Whoa. That post seems to be killing my brain.
    URK
    Join........us..........do not be..........afraid.......

  • Can you explain me clearly how to make company code visible in cost center

    can you explain me clearly how to make company code visible in cost center master data using tcode kmlv

    Hi,
    There is no way to activate the company code field. If your Controlling Area and Company Code have one to one Assignment, then Company code is defaulted from the Controlling Area. However, if multiple Company Codes are assigned to one Controlling Area, then Company Code becomes a mandatory field in the Cost Center master data
    Also, in case you have multiple company codes assigned to one controlling area, please check the setting of the Controlling Area in Configuration and see if have selected "Cross Company Code Cost Accounting" . Also, check if you have assigned all the company codes to the controlling area
    Regards
    Mahendra

Maybe you are looking for