Help with Bytes

Hi
Can anyone help me with the following example?
I have a 4 byte String s when displayed in binary =
00 30 00 00.
I would like to change the 30 which is equal to 48
to 79 which is equal to 121.
thanks

thank you for your help. but what should the value of
charset be?Most probably the encoding used for the original String. Since you're working with single-byte chars (don't you?), it seems "US-ASCII"'d be appropriate.
You may also ignore the charset and use the local one (use the no-arg getBytes()).

Similar Messages

  • Urgent Help with bytes

    Hi people, I'm in urgent need of help for a project I'm working on for my degree.
    Background: I am writing a package that will allow connectivity to a c++ server via streaming sockets. The c++ server sends/receives data as unsigned bytes. This is my problem as Java does not have unsigned bytes. The ideal would be to maintain it in the unsigned byte format as the form of any data passing through is unknown.
    I have currently implemented this using the channels and byteBuffers in 1.4. The reason for this was so that I could illiminate the BigEndian to LittleEndian problem. However I can't use them to write unsinged bytes that will be readable to the server. I'm guessing that I can change the unsigned bytes recieved into shorts but it's not great.
    Does anyone have any ideas or experience with this??

    I don't know if this helps...but I use the following method (with security manager removed) to download a binary file from anywhere on the net with no problem:
       public String aok_DownLoad(String inputFile, String outputFile) {
          try
             URL url=new URL(inputFile);
             InputStream in;
             URLConnection connection=url.openConnection();
             in=connection.getInputStream();
             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();
             return "1";
          catch (SecurityException exception) {
             exception.printStackTrace();
          catch (Throwable exception) {
             exception.printStackTrace();
       }V.V.

  • WRT310N: Help with DMZ/settings (firmware 1.0.09) for wired connection

    Hello. I have a WRT310N and have been having a somewhat difficult time with my xbox 360's connection. I have forwarded all the necessary ports (53, 80, 88, 3074) for it to run, and tried changing MTU and what-not.
    I don't know if I have DMZ setup incorrectly, or if it's my settings.
    Setup as follows:
    PCX2200 modem connected via ethernet to WRT310N. 
    The WRT310N has into ethernet port 1 a WAP54G, and then upstairs (so that my Mother's computer can get a strong signal) I have another WAP54G that I believe receives its signal from the downstairs 54G. 
    In the back of the WRT310N, I have my computer connected via ethernet port 3, and my Xbox 360 connected via ethernet port 4.
    Now, I first figured I just have so many connections tied to the router and that is the reason for being so slow. However, when I unplug all the other ethernet cords and nothing is connected wirelessly, except for my Xbox connected to ethernet port 4, it is still poor. Also, with everything connected (WAP54G and other devices wirelessly) I get on my PC and run a speedtest.  For the sake of advice, my speedtests I am running on my PC are (after 5 tests) averagely 8.5 Mbps download, and 1.00 Mbps upload, with a ping of  82ms.
    Here is an image of the results:
    http://www.speedtest.net][IMG]http://www.speedtest.net/result/721106714.png
    Let me add a little more detail of my (192.168.1.1) settings for WRT310N.
    For starters, my Father's IT guy at his workplace set up this WRT310N and WAP54G's. So some of these settings may be his doing. I just don't know which.
    "Setup" as Auto-configurations DHCP. I've added my Xbox's IP address to the DHCP reservation the IP of 192.168.1.104. This has (from what I've noticed) stayed the same for days.
    MTU: Auto, which stays at 1500 when I check under status.
    Advanced Routing: NAT routing enabled, Dynamic Routing disabled. 
    Security: Disabled SPI firewall, UNchecked these: Filter Anonymous Internet Requests, Multicast, and Internet NAT redirection.
    VPN passthrough: All 3 options are enabled (IPSec, PPTP, L2TP)
    Access Restrictions: None.
    Applications and Gaming: Single port forwarding has no entries. Port Range Forwarding I have the ports 53 UDP/TCP, 88 UDP, 3074 UDP/TCP, and 80 TCP forwarded to IP 192.168.1.104 enabled. (192.168.1.104 is the IP for my xbox connected via ethernet wired that is in DHCP reserved list)
    Port Range Triggering: It does not allow me to change anything in this page.
    DMZ: I have it Enabled. This is where I am a bit confused. It says "Source IP Address" and it has me select either "Any IP address" or to put entries to the XXX.XXX.XXX.XXX to XXX fields. I have selected use any IP address. Then the source IP area, it says "Destination:"  I can do either "IP address: 192.168.1.XXX" or "MAC address:" Also, under MAC Address, it says DHCP Client Table and I went there and saw my Xbox under the DHCP client list (It shows up only when the Xbox is on) and selected it.  
    Under QoS: WMM Enabled, No acknowledgement disabled.
    Internet Access Priority: Enabled. Upstream Bandwith I set it to Manual and put 6000 Kbps. I had it set on Auto before, but I changed it. I have no idea what to put there so I just put a higher number. 
    Then I added for Internet Access Priority a Medium Priority for Ethernet Port 4 (the port my xbox is plugged into).
    Administration: Management: Web utility access: I have checked HTTP, unchecked HTTPS.
    Web utility access via Wireless: Enabled. Remote Access: Disabled.
    UPnp: Enabled.
    Allow Users to Configure: Enabled.
    Allow users to Disable Internet Access: Enabled.
    Under Diagnostics, when I try and Ping test 192.168.1.104 (xbox when on and connected to LIVE), I get:
    PING 192.168.1.104 (192.168.1.104): 24 data bytes
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    --- 192.168.1.104 data statistics ---
    5 Packets transmitted, 0 Packets received, 100% Packet loss
    Also, when I do Traceroute Test for my Xbox's IP, I just keep getting: 
    traceroute to 192.168.1.104 (192.168.1.104), 30 hops max, 40 byte packets
    1 * * * 192.168.1.1 Request timed out.
    2 * * * 192.168.1.1 Request timed out.
     As for the Wireless Settings, it is all on the default settings with Wi-Fi Protected setup Enabled.
    To add, I have tried connecting my modem directly to the Xbox and my connection is much improved. I have no difficulty getting the NAT open, for it seems my settings are working for that. Any help with these settings would be VERY much appreciated. 
    Message Edited by CroftBond on 02-18-2010 01:09 PM

    I own 2 of these routers (one is a spare) with the latest firmware and I have been having trouble with them for over a year.  In my case the connection speed goes to a crawl and the only way to get it back is to disable the SPI firewall.  Rebooting helps for a few minutes, but the problem returns.  All of the other fixes recommended on these forums did not help.  I found out the hard way that disabling the SPI Firewall also closes all open ports ignoring your port forwarding settings.  If you have SPI Firewall disabled, you will never be able to ping your IP from an external address.  Turn your SPI Firewall back on and test your Ping. 
    John

  • I need help with Creating Key Pairs

    Hello,
    I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
    the class is :
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import au.net.aba.crypto.provider.ABAProvider;
    class CreateKeyPairs {
    private static KeyPair keyPair;
    private static KeyPairGenerator pairGenerator;
    private static PrivateKey privateKey;
    private static PublicKey publicKey;
    public static void main(String[] args) throws Exception {
    if (args.length != 2) {
    System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
    return;
    createKeys();
    saveKey(args[0],publicKey);
    saveKey(args[1],privateKey);
    private static void createKeys() throws Exception {
    Security.addProvider(new ABAProvider());
    pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
    pairGenerator.initialize(1024, new SecureRandom());
    keyPair = pairGenerator.generateKeyPair();
    privateKey = keyPair.getPrivate();
    publicKey = keyPair.getPublic();
    private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    the public key is:
    �� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�|  xpt Javaur [Ljava.lang.String;��V��{G  xp   q ~ ur [B���T�  xp   ��ccR}o���[!#I����lo������
    ����^"`8�|���Z>������&
    d ����"B��
    ^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
    How i can generated the key pairs in base 64 or binary????
    Thanxs for help me
    Luis Navarro Nu�ez
    Santiago.
    Chile.
    South America.

    I don't use ABA but BouncyCastle
    this could help you :
    try
    java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
    java.security.KeyPair kp = kg.generateKeyPair();
    java.security.Key pub = kp.getPublic();
    java.security.Key pri = kp.getPrivate();
    System.out.println("pub: " + pub);
    System.out.println("pri: " + pri);
    byte[] pub_e = pub.getEncoded();
    byte[] pri_e = pri.getEncoded();
    java.io.PrintWriter o;
    java.io.DataInputStream i;
    java.io.File f;
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
    o.println(new sun.misc.BASE64Encoder().encode(pub_e));
    o.close();
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
    o.println(new sun.misc.BASE64Encoder().encode(pri_e));
    o.close();
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
    StringBuffer keyBase64 = new StringBuffer();
    String line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
    keyBase64 = new StringBuffer();
    line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
    java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
    System.out.println("pub: " + pubKey);
    java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
    System.out.println("pri: " + priKey);
    catch(Exception e)
    e.printStackTrace ();
    }

  • Need help with a simple process with FTP Adapter and File Adapter

    I am trying out a simple BPEL process that gets a file in opaque mode from a FTP server using a FTP adapter and writes it to the local file system using a File Adapter. However, the file written is always empty (zero bytes). I then tried out the FTPDebatching sample using the same FTP server JNDI name and this work fine surprisingly. I also verified by looking at the FTP server logs that my process actually does hit the FTP server and seems to list the files based on the filtering condition - but it does not issue any GET or RETR commands to actually get the files. I am suspecting that the problem could be in the Receive, Assign or Invoke activities, but I am not able identify what it is.
    I can provide additional info such as the contents of my bpel and wsdl files if needed.
    Would appreciate if someone can help me with this at the earliest.
    Thanks
    Jay

    persiandude wrote:
    Topic: Need help with if, else, and which statements and loops.
    How would I display 60 < temp. <= 85 in java
    System.out.println("60 < temp. <= 85 in java");
    another question is how do I ask a question like want to try again (y/n) after a output and asking that everytime I type in yes after a output and terminate when saying No.Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
    Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    [http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
    Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
    Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
    James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806].

  • Need Help with data type conversion

    Hello People,
    I am new to java, i need some help with data type conversion:
    I have variable(string) storing IP Address
    IPAddr="10.10.103.10"
    I have to call a library function which passes IP Address and does something and returns me a value.
    The problem I have is that external function call in this library excepts IP Address in form of a byte array.
    Here is the syntax for the function I am calling through my program
    int createDevice (byte[] ipAddress).
    now my problem is I don't know how to convert the string  IPAddr variable into a byte[] ipAddress to pass it through method.

    Class InetAddress has a method
    byte[]      getAddress() You can create an instance using the static method getByName() providing the IP address string as argument.

  • Help with Sort function in Terminal

    Hello all... this is my first post on here as I'm having some trouble with some Termianl commands. I'm trying to learn Terminal at the moment as it is but I would appreciate some help with this one....
    I'm trying to sort a rather large txt file into alphabetical order and also delete any duplicates. I've been using the following command in Terminal:
    sort -u words.txt > words1.txt
    but after a while I get the following error
    sort: string comparison failed: Illegal byte sequence
    sort: Set LC_ALL='C' to work around the problem.
    sort: The strings compared were `ariadnetr\345dens\r' and `ariadnetr\345ds\r'.
    What should my initial command be? What is Set LC_ALL='C'?
    Hope you guys can help?

    Various languages distinct sorting - collation - sequences. 
    The characters can and variously do sort differently, depending on what language is involved. 
    Languages here can include the written languages of humans, and a few settings associated with programming languages.  This is all part of what is known as internationalization and localization, and there are are various documents around on that topic.
    The LC_ALL environment variable sets all of the locale-related settings en-mass, including the collation sequence that is established via LC_COLLATE et al, and the sort tool is suggesting selecting the C language collation.
    Here, the tool is suggesting the following syntax:
    LC_ALL=C sort -u words.txt > words1.txt
    This can also be done by exporting the LC_ALL, but it's probably better to just do this locally before invoking the tool.
    Also look at the lines of text in question within the files, and confirm the character encoding of the file.
    Files can have different character encodings, and there's no reliable means to guess the encoding.  For some related information, see the file command:
    file words.txt
    ...and start reading some of the materials on internationalization and localization that are posted around the 'net. Here's Apple's top-level overview.
    In this case, it looks like there's an "odd" character and probably an å character on that line and apparently the Svenska ariadnetrådens. 
    Switching collation can help here, or - if the character is not necessary - removing it via tr or replacing it via sed can be equally effective solutions. 
    Given it appears to be Svenska, it might work better to switch to Svenska collation thanto  the suggested C collation.
    I think that's going to be sv_SE, which would make the command:
    LC_ALL=sv_SE sort -u words.txt > words1.txt
    This is all generic bash shell scripting stuff, and not specific to OS X.  If you haven't already seen them, the folks over at tldp have various guides including a bash guide for beginners, and an advanced bash scripting guide - both can be worth skimming.  They're not exactly the same as bash on OS X and some specific commands and switches can differ, and as bash versions can differ, but bash is quite similar across all the platforms.

  • Help with java mapping

    PI File adapter has a processing option u2018Empty-Message Handlingu2019 to ignore or Write Empty Files. In case there is no data created after mapping on target side then this option determines whether to write an empty file or not. But there is a catch to this option when it comes to using it with File Content Conversion which is described in SAP Note u2018821267u2019. It states following:
    I configure the receiver channel with File content conversion mode and I set the 'Empty Message Handling' option to ignore. Input payload to the receiver channel is generated out of mapping and it does not have any record sets. However, this payload has a root element. Why does file receiver create empty output file with zero byte size in the target directory?  Example of such a payload generated from mapping is as follows:                                                           
    <?xml version="1.0" encoding="UTF-8"?>                          
    <ns1:test xmlns:ns1="http://abcd.com/ab"></ns1:test>
    solution :
    If the message payload is empty (i.e., zero bytes in size), then File adapter's empty message handling feature does NOT write files into the target directory. On the other hand, if the payload is a valid XML document (as shown in example) that is generated from mapping with just a root element in it, the File Adapter does not treat it as an empty message and accordingly it writes to the target directory. To achieve your objective of not writing files (that have just a single root element) into the target directory, following could be done:
    Using a Java or ABAP Mapping in order to restrict the creation of node itself during mapping. (This cannot be achieved via Message Mapping)
    Using standard adapter modules to do content conversion first and then write file. 
    can someone help with java mapping that can be used in this case?

    Hi,
        You have not mentioned the version of PI you are working in. In case you are working with PI 7.1 or above then here is the java mapping code you need to add after message mapping in the same interface mapping
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    public class RemoveRootNode extends AbstractTransformation{
         public void execute(InputStream in, OutputStream out)
         throws StreamTransformationException {
    // TODO Auto-generated method stub
    try
         DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder builderel=factory.newDocumentBuilder();
         /*input document in form of XML*/
         Document docIn=builderel.parse(in);
         /*document after parsing*/
         Document docOut=builderel.newDocument();
         TransformerFactory tf=TransformerFactory.newInstance();
         Transformer transform=tf.newTransformer();
         if(docIn.getDocumentElement().hasChildNodes())
              docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
              transform.transform(new DOMSource(docOut), new StreamResult(out));
         else
              out.write(null);
    catch(Exception e)
    public void setParameter(Map arg0) {
    // TODO Auto-generated method stub
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
         RemoveRootNode genFormat=new RemoveRootNode();
         FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
         FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
         genFormat.execute(in,out);
         catch(Exception e)
         e.printStackTrace();
    public void transform(TransformationInput arg0, TransformationOutput arg1)
              throws StreamTransformationException {
         // TODO Auto-generated method stub
         this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
    In case you are working in PI 7.0 you can use this code
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    public class RemoveRootNode implements StreamTransformation{
         public void execute(InputStream in, OutputStream out)
         throws StreamTransformationException {
    // TODO Auto-generated method stub
    try
         DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder builderel=factory.newDocumentBuilder();
         /*input document in form of XML*/
         Document docIn=builderel.parse(in);
         /*document after parsing*/
         Document docOut=builderel.newDocument();
         TransformerFactory tf=TransformerFactory.newInstance();
         Transformer transform=tf.newTransformer();
         if(docIn.getDocumentElement().hasChildNodes())
              docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
              transform.transform(new DOMSource(docOut), new StreamResult(out));
         else
              out.write(null);
    catch(Exception e)
    public void setParameter(Map arg0) {
    // TODO Auto-generated method stub
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
         RemoveRootNode genFormat=new RemoveRootNode();
         FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
         FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
         genFormat.execute(in,out);
         catch(Exception e)
         e.printStackTrace();
    The code for PI 7.0 should also work for PI 7.1 provided you use the right jar files for compilation, but vice-versa is not true.
    Could you please let us know if this code was useful to you or not?
    Regards
    Anupam
    Edited by: anupamsap on Dec 15, 2011 9:43 AM

  • Help with splitting a file

    I'm Starting in Java programing and need some help.
    Based in the information of txt file, I need to split a file.txt into "n" .txt files, depending of the blocks thats the file containt. It's delimited by """".
    And put the name between "UZ0RN0" the second field
    Example:
    "01APR02","UZ0RN0","******************************************
    EMHA PNR.UZ0RN0 CR01APR 0419Z MEX BY GS BT
    MEX GS BT 01APR 0421Z 385310 MX
    "01APR02","TSCS44","******************************************
    etc.
    My question is how do I split a file into parts eg split test.txt into UZ0RN0.txt, TSCS44.txt, etc.
    Pls help. Where do I start? I just need help with the the manage of the java.nio.channels.FileChannel to generate several files
    Thanks a lot.

    Ok Thats is the final code:
    This program divide a file.txt in "n" files.txt's according of the block's that the file.txt contain and catch the name of the second tokent to name the new file.txt
    import java.io.*;
    import java.nio.*;
    import java.nio.ByteBuffer;
    import java.nio.channels.FileChannel;
    public class FileCopy {
         public static void main(String[] args) {
              if(args.length==0) {
                   System.out.println("No existe archivo a copiar. Application usage is: \n" +
                                            "java -classpath. Filecopy \" filepath\"" );
                   System.exit(1);
              File fromFile = new File(args[0]);
              if(!fromFile.exists()) {
                   System.out.println("Archivo a copiar. " + fromFile.getAbsolutePath()
                                       + ", no existe.");
                   System.exit(1);
              FileInputStream inFile = null;
              try{
                   inFile = new FileInputStream(fromFile);
              } catch(FileNotFoundException e) {
                   e.printStackTrace(System.err);
                   //assert false;
              FileChannel inChannel = inFile.getChannel();
              try{
              int SizeFile = (int)inChannel.size();
              ByteBuffer buf = ByteBuffer.allocate(SizeFile);
              int length = 0;
              int lengthArch = 0;
              int NoArch = 0;
              int NoComilla = 0;
              String str = new String("");
              try{
                   while ((length = inChannel.read(buf)) != -1 ) {
                        buf.rewind();
                        for (int i=0; i<length; i++) {
                        lengthArch++;
                        byte b = buf.get();
                        //Delimita caracter. Cada bloque tiene 6 "'s
                        if ( b == 34 ) {
                             NoArch++;
                             NoComilla++;
                        //Definir nombre del archivo
                        if (NoComilla==3) {
                             if ( b!=34) {
                             str += (char)b;
                        //Imprime archivo
                        if (NoComilla==6) {
                             fromFile = fromFile.getAbsoluteFile();                         //Asegura una ruta absoluta
                             File parentDir = new File(fromFile.getParent());          //Obtiene el directorio
                             File bFile = new File(parentDir,str + ".txt");               //Genera nuevo archivo
                             str = ("");
                             File toFile1 = createFile(bFile);
                             FileOutputStream outFile1 = null;
                             try{
                                  outFile1 = new FileOutputStream(toFile1);
                             } catch(FileNotFoundException e) {
                                  e.printStackTrace(System.err);
                                  //assert false;
                             FileChannel outChannel1 = outFile1.getChannel();
                             // Write the files
                             try {
                             inChannel.transferTo(((i + 1) - lengthArch),lengthArch,outChannel1);
                             outFile1.close(); // Close the output stream & the channel
                             System.out.println("Archivo " + (NoArch/6) +": " + ((i +1) - lengthArch) + " long " + lengthArch);
                             } catch(IOException e) {
                                  e.printStackTrace(System.err);
                                  System.exit(1);
                             lengthArch = 0;
                             NoComilla = 0;
                        //System.out.print((char)b);
                   buf.clear();
              System.out.println("Tamano del archivo de Origen " + SizeFile);
              System.out.println("EOF " + (NoArch/6) + " Archivos copiados.");
              catch(IOException e) {
                   e.printStackTrace(System.err);
                   System.exit(1);
              inFile.close();
              } catch(IOException e) {
                   e.printStackTrace(System.err);
                   System.exit(1);
              System.exit(0);
         // Metodo para crear un achivo y en caso de que exista hacer *+_backup.*
         public static File createFile(File aFile) {
              aFile = aFile.getAbsoluteFile();                         //Asegura una ruta absoluta
              File parentDir = new File(aFile.getParent());          //Obtiene el directorio
              String name = aFile.getName();                              //Obtiene el nombre del archivo
              int period = name.indexOf('.');                              //Busca el separador de la extension
              if(period == -1)                                             //Si no es
                   period = name.length();                                   //Lo coloca al final del String
              String nameAdd = "_backup";                                   //Agrega "Backup" al nombre
              //Crea el objeto archivo que es unico
              File backup = new File(name.substring(0,period)
                                       + name.substring(period));
              while (backup.exists()) {                                   //Si el nombre ya existe....
                   name = backup.getName();                              //Obtiene el nombre actual del archivo
                   period += nameAdd.length();                              //Agrega el separador
                   backup = new File(parentDir, name.substring(0,period) //agrega backup de nuevo
                                       + nameAdd + name.substring(period));
              return backup;
    This is the example of the file with 2 blocks
    "01APR02","UZ0RN0","******************************************
    EMHA PNR.UZ0RN0 CR01APR 0419Z MEX BY GS BT
    385310 MX
    ***1.ALCANTARA/JORGEALBERTO
    FONE-MEX/N000
    RCVD-PAX
    TKT -T/OK
    1 MX 7M 01APR MEXMTY HK 1 650A 815A
    AB * FLT 7 7A
    RCVD-PAX
    MEX GS BT 01APR 0419Z 385310 MX
    AB | FLT 7 7A
    RCVD-PAX
    MEX GS BT 01APR 0421Z 385310 MX
    "01APR02","TSCS44","******************************************
    .... PNR.TSCS44 CR25MAR 1834Z HDQ BY RM 1S
    ***1.1BRAVO/OCTAVIO
    FONE-MTY1-81503300*A/A528
    RLOC-HDQ1SJOXMWV/D4C2/86511574/MTY/1S/T/MX
    /MXN
    G FX-OSI YY 86511574 / VILLATOURS CENTRO P
    CC D4C2
    OSI MX TKNA 13235822315830
    SSRSEATMXHS1MTYMEX0070K28MAR.16B
    SSRSEATMXHS1MEXMTY0007K01APR.09B
    1 MX 70K 28MAR MTYMEX HK 1 645A 815A
    2 MX 7K 01APR MEXMTY HK 1 650A 815A
    X3 SSRSEATMXNN1MTYMEX0070K28MAR.16B
    RCVD-
    HDQ RM 1S 25MAR 2205Z
    X3 SSRSEATMXNN1MEXMTY0007K01APR.09B
    RCVD-
    HDQ RM 1S 25MAR 2231Z
    X3 SSRSEATMXKK1MTYMEX0070K28MAR.16BN
    X3 SSRSEATMXKK1MEXMTY0007K01APR.09BN
    RCHDQ1SJOXMWV/D4C2/86511574/MTY/1S/T/MX
    /MXN
    HDQ RM 1S 26MAR 0055Z
    Chao/Bye

  • Help with the problem query

    Hi,
    I have another query running slow when executed from cognos. It is also not returning any output continues to execute,
    with "Union15" as (
    select distinct CASE WHEN(substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end  IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 1, 4)||case substr(to_char(FLOOR("EES_ENERGY_MASTER"."DISC_MON"/100)), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END "QUARTER", "EES_ENERGY_MASTER"."PAT_KEY" "Cases_Using_Energy", 0 "Total_Cases"
    from "MDM_DBA"."EES_ENERGY_MASTER" "EES_ENERGY_MASTER", "MDM_DBA"."EES_CONS_PROV" "EES_CONS_PROV"
    where "EES_ENERGY_MASTER"."DISC_MON">=2006101 and "EES_ENERGY_MASTER"."PDCT_CAT"='Energy' and substr("EES_ENERGY_MASTER"."ICD_CODE", 1, 2)='68-gyn' and "EES_ENERGY_MASTER"."MANUFACTURER"='EES' and "EES_CONS_PROV"."CONS_06_09_YN" in ('N', 'Y') and "EES_ENERGY_MASTER"."PROV_ID"="EES_CONS_PROV"."PROV_ID" union 
    select CASE WHEN(substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end  IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4)||case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END "QUARTER", 0 "Cases_Using_Energy", count("MVW_EES_ICD_STATS"."CASES") "Total_Cases"
    from "MDM_DBA"."MVW_EES_ICD_STATS" "MVW_EES_ICD_STATS", "MDM_DBA"."EES_CONS_PROV" "EES_CONS_PROV", "MDM_DBA"."EES_HOSP_CHG_PROV" "EES_HOSP_CHG_PROV"
    where "MVW_EES_ICD_STATS"."DISC_QTR">=20061 and "MVW_EES_ICD_STATS"."ICD_GROUP"='68-gyn' and "EES_CONS_PROV"."CONS_06_09_YN" in ('N', 'Y') and "EES_HOSP_CHG_PROV"."PDCT_CAT"='Energy' and "EES_HOSP_CHG_PROV"."MANUFACTURER"='EES' and "MVW_EES_ICD_STATS"."PROV_ID"="EES_CONS_PROV"."PROV_ID" and "MVW_EES_ICD_STATS"."PROV_ID"="EES_HOSP_CHG_PROV"."PROV_ID"
    group by CASE WHEN(substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4) IS NULL) OR (case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end  IS NULL) THEN NULL ELSE (substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 1, 4)||case substr(to_char(FLOOR("MVW_EES_ICD_STATS"."DISC_QTR")), 5, 1) when '1' then 'Q1' when '2' then 'Q2' when '3' then 'Q3' when '4' then 'Q4' end ) END)
    select "T1"."C0" "levelkey", "T1"."C1" "Cases_Using_Energy", "T0"."C0" "Cases_Using_Energy1", "T1"."C2" "Total_Cases"
    from (
    select count(distinct "Union15"."Cases_Using_Energy") "C0"
    from "Union15") "T0", (
    select "Union15"."QUARTER" "C0", count(distinct "Union15"."Cases_Using_Energy") "C1", sum("Union15"."Total_Cases") "C2"
    from "Union15"
    group by "Union15"."QUARTER") "T1"The explain plan is as follows,
    PLAN_TABLE_OUTPUT
    | Id  | Operation                             |  Name                        | Rows  | Bytes |TempSpc| Cost  |
    |   0 | SELECT STATEMENT                      |                              |     1 |    50 |       |    22 |
    |   2 |  TEMP TABLE TRANSFORMATION            |                              |       |       |       |       |
    |   1 |   RECURSIVE EXECUTION                 | SYS_LE_2_0                   |       |       |       |       |
    |   0 |    INSERT STATEMENT                   |                              |  3053 |   128K|       |  1372 |
    |   1 |     LOAD AS SELECT                    |                              |       |       |       |       |
    |   2 |      SORT UNIQUE                      |                              |  3053 |   128K|   376K|  1372 |
    |   3 |       UNION-ALL                       |                              |       |       |       |       |
    |*  4 |        HASH JOIN                      |                              |  3052 |   128K|       |   185 |
    |*  5 |         TABLE ACCESS FULL             | EES_CONS_PROV                |   622 |  3732 |       |     2 |
    |*  6 |         TABLE ACCESS BY INDEX ROWID   | EES_ENERGY_MASTER            |  3055 |   110K|       |   182 |
    |*  7 |          INDEX RANGE SCAN             | IDX_ENERGY_PDCT_CAT          |  1978 |       |       |  2478 |
    |   8 |        SORT GROUP BY                  |                              |     1 |    40 |       |  1160 |
    |*  9 |         TABLE ACCESS BY INDEX ROWID   | EES_HOSP_CHG_PROV            |     4 |    72 |       |     1 |
    |  10 |          NESTED LOOPS                 |                              |     1 |    40 |       |  1157 |
    |  11 |           NESTED LOOPS                |                              |     1 |    22 |       |  1156 |
    |* 12 |            TABLE ACCESS BY INDEX ROWID| MVW_EES_ICD_STATS            |     1 |    16 |       |  1155 |
    |* 13 |             INDEX RANGE SCAN          | MVWICDSTATS_DISCQTR_IDX      |    13M|       |       | 26068 |
    |* 14 |            TABLE ACCESS BY INDEX ROWID| EES_CONS_PROV                |     1 |     6 |       |     1 |
    |* 15 |             INDEX UNIQUE SCAN         | EES_CONS_PROV_PK             |     1 |       |       |       |
    |* 16 |           INDEX RANGE SCAN            | PROV_ID_IDX_2                |    65 |       |       |     1 |
    |   3 |   MERGE JOIN CARTESIAN                |                              |     1 |    50 |       |    22 |
    |   4 |    VIEW                               |                              |     1 |    13 |       |     3 |
    |   5 |     SORT GROUP BY                     |                              |     1 |    13 |       |       |
    |   6 |      VIEW                             |                              |  3053 | 39689 |       |     3 |
    |   7 |       TABLE ACCESS FULL               | SYS_TEMP_0FD9D68B3_C112F95D  |  3053 |   110K|       |     3 |
    |   8 |    VIEW                               |                              |     1 |    37 |       |    19 |
    |   9 |     SORT GROUP BY                     |                              |     1 |    37 |       |    19 |
    |  10 |      VIEW                             |                              |  3053 |   110K|       |     3 |
    |  11 |       TABLE ACCESS FULL               | SYS_TEMP_0FD9D68B3_C112F95D  |  3053 |   110K|       |     3 |
    Predicate Information (identified by operation id):
       4 - access("EES_ENERGY_MASTER"."PROV_ID"="EES_CONS_PROV"."PROV_ID")
       5 - filter("EES_CONS_PROV"."CONS_06_09_YN"='N' OR "EES_CONS_PROV"."CONS_06_09_YN"='Y')
       6 - filter("EES_ENERGY_MASTER"."DISC_MON">=2006101 AND SUBSTR("EES_ENERGY_MASTER"."ICD_CODE",1,2)='68-gyn'
                  AND "EES_ENERGY_MASTER"."MANUFACTURER"='EES')
       7 - access("EES_ENERGY_MASTER"."PDCT_CAT"='Energy')
       9 - filter("EES_HOSP_CHG_PROV"."PDCT_CAT"='Energy' AND "EES_HOSP_CHG_PROV"."MANUFACTURER"='EES')
      12 - filter("MVW_EES_ICD_STATS"."ICD_GROUP"='68-gyn')
      13 - access("MVW_EES_ICD_STATS"."DISC_QTR">=20061 AND "MVW_EES_ICD_STATS"."DISC_QTR" IS NOT NULL)
      14 - filter("EES_CONS_PROV"."CONS_06_09_YN"='N' OR "EES_CONS_PROV"."CONS_06_09_YN"='Y')
      15 - access("MVW_EES_ICD_STATS"."PROV_ID"="EES_CONS_PROV"."PROV_ID")
      16 - access("MVW_EES_ICD_STATS"."PROV_ID"="EES_HOSP_CHG_PROV"."PROV_ID")
    Please help with some solution.

    OK: the third parameter of the SUBSTR function indicates the (maximum) length of the returnd string.
    Therefore SUBSTR("EES_ENERGY_MASTER"."ICD_CODE",1,2) could possibly be '68' , but never '68-gyn'.
    '68-gyn' is just 4 characters too long.
    Urs

  • Help with production jvm issues at customer site

    Following is a brief overview of two production issues experienced by an Oracle customer. Customer is currently running 32 bit Java 1.5_20 on Solaris 64 bit OS.
    1)     OOM heap issues – SR #3-2611053901 – Recently we have been seeing OOM errors due to heap space. What we have seen is that some of the instances are not able to free up any memory space even after full GC, which results into a series of full GC’s back to back and eventually leads to OOM. During this time when continuous full GC is going on, we have seen the TCP connections and active JDBC connections shoot up and also lots of stuck threads. This error occurs during peak hours.
    This is the output just before OOM. Just to be clear, this line is printed as last line of Full GC which meant that OOM happened right after Full GC:
    [PSYoungGen: 111616K->82323K(172544K)] [PSOldGen: 1865727K->1865727K(1865728K)] 1977343K->1948051K(2038272K) [PSPermGen: 209111K->209061K(210944K)] GC time is exceeding GCTimeLimit of 98%, 13.3644395 secs]
    2)     OOM swap space- SR: #3-1724941721 – From time to time, we get Exception in thread "CompilerThread0" java.lang.OutOfMemoryError: requested 32756 bytes for ChunkPool::allocate. Out of swap space?’ error in our production. Mostly this error occurs during off hours or off-peak hours. When this happen, there is plenty of heap and perm memory available which indicates that this is a native memory error. We already put two workarounds suggested by Oracle i.e. -XX:CodeCacheMinimumFreeSpace=8m -XX:ReservedCodeCacheSize=128m but still running into this problem.
    What we are looking for:
    1)     Recommendations on tuning our config parameters -
    These are some recommendations we discussed internally. Please validate these recommendations and provide us the recommended values. We would also welcome any new recommendation on updating other parameters if that will help with our issues.
    •     Change Xmx to 2048m and MaxPermSize to 512m
    •     Specify ratio of young generation to old generation (-XX:NewRatio), and possibly survivor spaces.
    •     Use Concurrent old generation collector (-XX:+UseConcMarkSweepGC), with a compatible parallel young generation collector (-XX:+UseParNewGC)
    Our current config settings are:
    JAVA Memory arguments: -Did=chaserels-cm21 -Xms1024m -Xmx2048m -XX:MaxPermSize=1024m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:CodeCacheMinimumFreeSpace=8m -XX:ReservedCodeCacheSize=128m -verbose:gc -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1641 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.awt.headless=true -Dfile.encoding=ISO646-US
    In a subset of servers, the settings are same as above but for MaxPermSIze, which is set to -XX:MaxPermSize=512m
    2)     Diagnostic help in how to further narrow down to the problem and what tool to use to gather heap dumps
    We have tried to take heap dump using jmap on our production servers when OOM occurs due to heap but most of the time, we run into an exception (attached - which is probably an unresolved jvm bug). While we researched some alternatives to jmap for taking heap dumps, most of these require changing the start-up scripts or installing the tool on production system which may have a performance overhead. What we want is a least intrusive tool which could provide us heap dumps/snapshots without much overhead and could be preferably used remotely. If there are other ways of collecting data than heap dump, we could also use them.
    Let me know if you have any questions or need any data.
    Thanks for your help.
    Error from heap dump :
    Exception in thread "main" sun.jvm.hotspot.debugger.UnalignedAddressException: Trying to read at address: 0xfec080a7 with alignment: 4
    at sun.jvm.hotspot.debugger.DebuggerUtilities.checkAlignment(DebuggerUtilities.java:40)
    at sun.jvm.hotspot.debugger.proc.ProcDebuggerLocal.readCInteger(ProcDebuggerLocal.java:309)
    at sun.jvm.hotspot.debugger.DebuggerBase.readAddressValue(DebuggerBase.java:425)
    at sun.jvm.hotspot.debugger.proc.ProcDebuggerLocal.readOopHandle(ProcDebuggerLocal.java:326)
    at sun.jvm.hotspot.debugger.proc.ProcAddress.getOopHandleAt(ProcAddress.java:96)
    at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:198)
    at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:346)
    at sun.jvm.hotspot.runtime.JavaThread.getThreadObj(JavaThread.java:333)
    at sun.jvm.hotspot.utilities.AbstractHeapGraphWriter.writeJavaThreads(AbstractHeapGraphWriter.java:113)
    at sun.jvm.hotspot.utilities.AbstractHeapGraphWriter.write(AbstractHeapGraphWriter.java:98)
    at sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:399)
    at sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:133)
    at sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:143)
    at sun.jvm.hotspot.tools.JMap.run(JMap.java:71)
    at sun.jvm.hotspot.tools.Tool.start(Tool.java:204)
    at sun.jvm.hotspot.tools.JMap.main(JMap.java:126)

    1)     OOM heap issues – SR #3-2611053901 – Recently we have been seeing OOM errors due to heap space. What we have seen is that some of the instances are not able to free up any memory space even after full GC, which results into a series of full GC’s back to back and eventually leads to OOM. Which would be exactly what would happen if there were many objects which were not eligible for collection.
    Causes would be either a bug (something not releasing something it should) or because the server is overloaded.
    If there were no code changes it could still be a bug that has now only become apparent due to changes in usage patterns.
    If that is the case then such bugs can usually be made more apparent by reducing the maximum heap. Doing that will cause it to occur faster.

  • Help with java digital signing code

    hello people.
    can anybody help me?
    i have find a java code to resolve my problem with sending pay in soap envelope with digital signature and attached certificate. i compiled it with jdk jdk1.6.0_37. and it works.
    i need it to work in built-in jvm in oracle 9i. in oracle 9i jvm release is 1.3.1. Java code does not work there. there is an error
    class import com.sun.org.apache.xerces.internal.impl.dv.util.Base64 not found in import.
    i did not find this class in network.
    can anybody help with rewriting it for jvm 1.3.1?
    thanks in advance.
    code below:
    import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
    import java.io.*;
    import java.security.Key;
    import java.security.KeyStore;
    import java.security.PrivateKey;
    import java.security.Signature;
    import java.security.cert.Certificate;
    public class Sign {
    public static void main(String[] args) throws Exception {
    // TODO code application logic here
    BufferedReader reader = new BufferedReader(new FileReader("c:\\cert.p12"));
    StringBuilder fullText = new StringBuilder();
    String line = reader.readLine();
    while (line != null) {
    fullText.append(line);
    line = reader.readLine();
    KeyStore p12 = KeyStore.getInstance("pkcs12");
    p12.load(new FileInputStream("c:\\cert.p12"), "Hfrtnf$5".toCharArray());
    //????????? ????????? ????, ??? ????? ????? ???????????? alias ? ??????
    //Key key = p12.getKey("my kkb key", "ryba-mech".toCharArray());
    Key key = (Key) p12.getKey("my kkb key", "Hfrtnf$5".toCharArray());
    Certificate userCert = (Certificate) p12.getCertificate("my kkb key");
    String base64Cert = new String(Base64.encode(userCert.getEncoded()));
    //signing
    Signature signer = Signature.getInstance("SHA1withRSA");
    signer.initSign((PrivateKey) key);
    signer.update(fullText.toString().getBytes());
    byte[] digitalSignature = signer.sign();
    String base64sign = new String(Base64.encode(digitalSignature));
    String base64Xml = new String(Base64.encode(fullText.toString().getBytes()));
    System.out.println("<certificate>" + base64Cert+"</certificate>");
    System.out.println("<xmlBody>" + base64Xml+"</xmlBody>");
    System.out.println("<signature>" + base64sign+"</signature>");
    Edited by: user13622283 on 22.01.2013 22:08

    My first search is to see if there is an Apache commons project that provides it. Lo and behold:
    http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
    commons-codec.

  • Need a little help with RAF logic

    So Im making a program to give different users, different rights. This is the method that appends them to file and Map
         * Writes the players rights to the appendages
         * @param playerName Player to update
         * @param playerRights Rights to give the player
         * @param pointer The lines index in the files
         * @throws IOException If a read/write error occours
        public void writeRights(String playerName, Rights playerRights, long pointer) throws IOException {
            rightsRAF.seek(pointer);
            rightsRAF.write(("\n" + playerName + "::" + playerRights).getBytes());
            if(rightsRAF.read() != '\n') {
                rightsRAF.seek(rightsRAF.getFilePointer()-1);
                rightsRAF.write("\n".getBytes());
            rightsMap.put(playerName, playerRights);
        }1. The RAF goes to the predetermined index in the file, pointer, which is the line the users name starts on. Entries are stored in the file as "name::RIGHTS"
    2.It writes out the players name, and rights
    3. It checks to see if it accidentally wrote over the \n
    My problem now, is that some rights are longer than others. For example, if there was already an entry, "name::MODERATOR" and you overwrite it, with "name::OWNER" then it would turn into "name::OWNERATOR" because the rest of the line wasn't overwritten.
    I need some help with logic to determine how to overwrote the entire line, because sometimes you could go from a short one, to a long one, and need to append a new \n character, and sometimes you could go the other way around from long to short and end up with two words fused, I cant figure out how to determine whats a word that got partially overwritten and whats a new line totally.
    Thanks

    As pointed out you need to have fixed size records, or at least a maximum size.
    You also have another problem nobody commented on yet (I don't think) with the getBytes() calls. At that point in your code you will mangle most unicode Strings.
    All things being equal here I think your best solution is to use an embedded database like JavaDB with JDBC. I think you will find an XML solution to slow for your purposes.
    If you decide to continue the RAF route though here is an example. I know this is not exactly what you are doing but you can extrapolate from this...
    public void updatePlayerName(String playerName, int playerIndex){
       int recordlength = 200;  
       byte[] buff = playerName.getBytes("UTF-8");
       if(buff.length>recordlength){
          //truncate bytes. this is also not great because a character at the end could be mangled
          byte[] temp = new byte[recordlength];
          System.arraycopy(buff,0,temp,0,temp.length);
          buff = temp;
       long pointer = playerIndex * (recordlength+4);// plus 4 bytes per record for actual length
       raf.seek(pointer);
       raf.writeInt(buff.length);
       raf.write(buff);
    public String getPlayerName(int playerindex){
        int recordlength = 200;  
        long pointer = playerIndex * (recordlength+4);
        raf.seek(pointer);
        int lengthToRead = raf.readInt();
        //length to read should be checked for sanity or bad things will happen next
        byte[] buff = new byte[lengthToRead];
        raf. readFully(buff);
        return new String(buff,"UTF-8");
    }And then of course you'd have to add storing the "rights". It gets complicated in a hurry. I do really recommend the JDBC route.

  • I need help with a query

    Hello everyone,
    First, some background information.  We have in place a table which records status changes on a work order.  The orders normally go through each status only once, however they do occasionally reuse status indicators.  For example, an order is placed on hold, released from hold, placed back on hold, released again and so on.  The sample data provided is an example of an order with data repeating itself.  I need some help with writing a query on this table.
    LOC_CODE
    WO_NO
    UPDATETIME
    WO_STATUS_OLD
    WO_STATUS_NEW
    xxx
    12345
    05-01-2013 10:24:00
    WR
    SP
    xxx
    12345
    05-01-2013 10:39:00
    SP
    PM
    xxx
    12345
    05-01-2013 11:52:00
    PM
    ES
    xxx
    12345
    05-01-2013 11:58:00
    ES
    MO
    xxx
    12345
    05-01-2013 12:03:00
    MO
    ES
    xxx
    12345
    05-01-2013 12:38:00
    ES
    AT
    xxx
    12345
    05-01-2013 12:48:00
    AT
    RS
    xxx
    12345
    05-01-2013 13:01:00
    RS
    RA
    xxx
    12345
    05-01-2013 13:26:00
    RA
    RS
    xxx
    12345
    05-01-2013 13:36:00
    RS
    RA
    xxx
    12345
    05-01-2013 15:35:00
    RA
    RS
    xxx
    12345
    05-01-2013 15:42:00
    RS
    RA
    xxx
    12345
    05-01-2013 16:04:00
    RA
    RS
    xxx
    12345
    05-01-2013 16:42:00
    RS
    RA
    xxx
    12345
    05-01-2013 19:28:00
    RA
    FD
    xxx
    12345
    05-01-2013 19:28:00
    FD
    SO
    The query (which will in turn be used for a view) will display the elapsed time between status updates (subtract updatetime from the record preceeding).  Only the first record for each order at a location would have no elapsed time.  The result should look like this:
    LOC_CODE
    WO_NO
    UPDATETIME
    WO_STATUS_OLD
    WO_STATUS_NEW
    MINUTES_ELAPSED
    xxx
    12345
    05-01-2013 10:24:00
    WR
    SP
    {null}
    xxx
    12345
    05-01-2013 10:39:00
    SP
    PM
    15
    xxx
    12345
    05-01-2013 11:52:00
    PM
    ES
    73
    xxx
    12345
    05-01-2013 11:58:00
    ES
    MO
    6
    xxx
    12345
    05-01-2013 12:03:00
    MO
    ES
    5
    xxx
    12345
    05-01-2013 12:38:00
    ES
    AT
    35
    xxx
    12345
    05-01-2013 12:48:00
    AT
    RS
    10
    xxx
    12345
    05-01-2013 13:01:00
    RS
    RA
    13
    xxx
    12345
    05-01-2013 13:26:00
    RA
    RS
    25
    xxx
    12345
    05-01-2013 13:36:00
    RS
    RA
    10
    xxx
    12345
    05-01-2013 15:35:00
    RA
    RS
    119
    xxx
    12345
    05-01-2013 15:42:00
    RS
    RA
    7
    xxx
    12345
    05-01-2013 16:04:00
    RA
    RS
    22
    xxx
    12345
    05-01-2013 16:42:00
    RS
    RA
    38
    xxx
    12345
    05-01-2013 19:28:00
    RA
    FD
    166
    xxx
    12345
    05-01-2013 19:28:00
    FD
    SO
    0
    I have been trying various queries, but no luck as of yet.  I would appreciate your input.
    Thank you,
    Patrick

    Sorry about the late reply.  I had an unexpected meeting to attend.  Here is the requested information
    We are running Oracle Database 11g Release 11.2.0.3.0 - 64bit Production.
    --  DDL for Table WO_STATUS
      CREATE TABLE "WO_STATUS"
       ( "LOC_CODE" VARCHAR2(3 BYTE),
      "WO_NO" NUMBER,
      "UPDATE_DATETIME" DATE,
      "WO_STATUS_OLD" VARCHAR2(2 BYTE),
      "WO_STATUS_NEW" VARCHAR2(2 BYTE)
    INSERT INTO WO_STATUS (LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 10:24:00'},'WR','SP');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 10:39:00'},'SP','PM');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 11:52:00'},'PM','ES');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 11:58:00'},'ES','MO');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 12:03:00'},'MO','ES');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 12:38:00'},'ES','AT');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 12:48:00'},'AT','RS');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 13:01:00'},'RS','RA');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 13:26:00'},'RA','RS');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 13:36:00'},'RS','RA');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 15:35:00'},'RA','RS');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 15:42:00'},'RS','RA');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 16:04:00'},'RA','RS');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 16:42:00'},'RS','RA');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 19:28:00'},'RA','FD');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12345,{ts '2013-05-01 19:28:00'},'FD','SO');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12346,{ts '2013-06-18 09:35:00'},'PM','ES');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12346,{ts '2013-06-18 09:37:00'},'ES','AT');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12346,{ts '2013-06-18 09:45:00'},'AT','RS');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12346,{ts '2013-06-18 09:51:00'},'RS','RA');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12346,{ts '2013-06-18 10:01:00'},'RA','FD');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12346,{ts '2013-06-18 10:02:00'},'FD','SO');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12346,{ts '2013-06-18 10:23:00'},'SO','MP');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12347,{ts '2013-06-18 08:29:00'},'WR','SP');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12347,{ts '2013-06-18 09:07:00'},'SP','PM');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12347,{ts '2013-06-18 09:48:00'},'PM','ES');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12347,{ts '2013-06-18 09:51:00'},'ES','AT');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12347,{ts '2013-06-18 10:19:00'},'AT','FD');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12347,{ts '2013-06-18 10:20:00'},'FD','SO');
    INSERT INTO WO_STATUS(LOC_CODE,WO_NO,UPDATE_DATETIME,WO_STATUS_OLD,WO_STATUS_NEW) VALUES ('xxx',12347,{ts '2013-06-18 10:24:00'},'SO','PY');

  • Help with a simple 1811 configuration

    I have a very basic level of understanding with Cisco products and I need help with what should be simple and even doable by me.
    I have a Cisco 1811 integrated router and am simply trying to use it on my home network.  I can configure the router with an enable secret password, password encryption, VTY, aux, and cons logins with no issues.  The router has 2 Ethernet interfaces, 0 and 1 and 8 switch ports.
    The idea is to bring Comcast ISP service into one of the Ethernet ports and then have three machines on the switch ports able to access the Internet.  Also I have an off-the shelf wireless router that I thought I would just plug that into an available switch port and allow a wireless AP as well. 
    This is so simply, that I can't believe I can't figure it out, but I can't.
    I set int F1 to DHCP, performed a 'no shut', and connected the ISP's router and have an up and up indication.  I have setup a static network with my three machines on the switch ports and enabled all applicable ports and have up and up indications - however, no traffic flow, even amongst my static Layer 2 switched LAN - not even a 'ping'.  By my understanding of Layer 2, this should work right now, whether the ISP service is working or not - WHAT AM I DOING WRONG?
    The addressing scheme I have ended up on is 172.16.1.0/28
    Obviously without the first hurdle cleared, of why the switched LAN doesn’t work, I haven't got any deeper.  Do I need to configure NAT?  I don't think I would need to in the scenario right?
    All of my experience, and none at the CCNA level, has been with larger Cisco equipment.  One thing I noticed on the 1811 was that when trying to create a new VLAN, it appears to work yet does not do anything and the 'sh vlans' output returns nothing, not even the VLAN1 I can see with 'sh ip int brief". 
    Anyway, if anyone has time to help a newbie out I would appreciate it; I’m lost.
    Thanks,
    Josh

    Thanks for the help Andrew!  You know, I think if this was two separate devices (switch and router) I think I would be up and running, but this integrated stuff is throwing me off, not to mention that the IOS is a much older version (I guess) than what I'm used to. 
    They were throwing this 1811 in the trash can at work, so I just emptied the trash can.  I have no documentation at all but I have since found the 1800 series documentation on Cisco.com and have tried to implement the basic configurations cited; with what seems like success, but still no joy.  I did have to recover the password and did so with 0x2142, I bypassed the setup and compared the default configuration with what is listed in the documentation and they DO NOT match; I also tried to go through setup mode with the same indications.  Additionally I've also learned that the 1800 series is pre-configured on certain options (DHCP, VLAN), which is new to me - I thought Cisco routers were not configured by default - isn't that kind of the point?  (By the way, the below port status may not be correct since I now have all the ports unplugged)
    Anyway, here is the 'show run' command, the 'sh ip int brief' command, followed by the 'sh version' command:
    Show Run
    Casino#sh run                                                                 
    Building configuration...                                                     
    Current configuration : 2006 bytes                                            
    version 12.4                                                                  
    service timestamps debug datetime msec                                        
    service timestamps log datetime msec                                          
    service password-encryption                                                   
    hostname Casino                                                               
    boot-start-marker                                                             
    boot-end-marker                                                               
    enable secret 5 $1$meWw$nsMTp6US7axi/uE0MWULK.                                
    enable password 7 06535E741C1B584C55                                          
    no aaa new-model                                                              
    ip cef                                                                        
    no ip dhcp use vrf connected                                                  
    ip dhcp excluded-address 172.16.1.1                                           
    ip dhcp pool Casino                                                           
       import all                                                                 
       network 172.16.1.0 255.255.255.240                                         
       default-router 67.165.208.1                                                
       dns-server 68.87.89.150                                                    
       domain-name hsd1.co.comcast.net                                            
    no ip domain lookup                                                           
    ip domain name GinRummy.localhost                                             
    ip name-server 68.87.85.102                                                   
    ip name-server 68.87.69.150                                                   
    ip auth-proxy max-nodata-conns 3                                              
    ip admission max-nodata-conns 3                                               
    multilink bundle-name authenticated                                           
    archive                                                                       
    log config                                                                   
      hidekeys                                                                    
    interface Loopback0                                                           
    ip address 172.16.1.1 255.255.255.240                                        
    interface FastEthernet0                                                       
    no ip address                                                                
    shutdown                                                                     
    duplex auto                                                                  
    speed auto                                                                   
    interface FastEthernet1                                                       
    ip address dhcp                                                              
    ip nat outside                                                               
    ip virtual-reassembly                                                        
    duplex auto                                                                  
    speed auto                                                                   
    pppoe enable                                                                 
    pppoe-client dial-pool-number 1                                              
    interface BRI0                                                                
    no ip address                                                                
    encapsulation hdlc                                                           
    shutdown                                                                     
    interface FastEthernet2                                                       
    interface FastEthernet3                                                       
    interface FastEthernet4                                                       
    interface FastEthernet5                                                       
    interface FastEthernet6                                                       
    interface FastEthernet7                                                       
    interface FastEthernet8                                                       
    interface FastEthernet9                                                       
    interface Vlan1                                                               
    no ip address                                                                
    ip nat inside                                                                
    ip virtual-reassembly                                                        
    interface Dialer0                                                             
    ip address negotiated                                                        
    ip mtu 1492                                                                  
    encapsulation ppp                                                            
    dialer pool 1                                                                
    ppp authentication chap                                                      
    ip forward-protocol nd                                                        
    no ip http server                                                             
    no ip http secure-server                                                      
    ip nat pool Casino 172.16.1.2 172.16.1.14 netmask 255.255.255.240             
    ip nat inside source list 1 interface Dialer0 overload                        
    access-list 1 permit 172.16.1.0 0.0.0.15                                      
    dialer-list 1 protocol ip permit                                              
    control-plane                                                                 
    line con 0                                                                    
    password 7 080E5916584B4442435E5C                                            
    login                                                                        
    line aux 0                                                                    
    password 7 013C135C0A59475A70191E                                            
    login                                                                        
    line vty 0 4                                                                  
    password 7 09635B51485756475A5954                                            
    login                                                                        
    end                                                                           
    Show IP Interface Brief
    Casino#sh ip int brief                                                        
    Interface                  IP-Address      OK? Method Status                Prl
    FastEthernet0              unassigned      YES NVRAM  administratively down do
    FastEthernet1              unassigned      YES DHCP   up                    do
    BRI0                       unassigned      YES NVRAM  administratively down do
    BRI0:1                     unassigned      YES unset  administratively down do
    BRI0:2                     unassigned      YES unset  administratively down do
    FastEthernet2              unassigned      YES unset  up                    do
    FastEthernet3              unassigned      YES unset  up                    do
    FastEthernet4              unassigned      YES unset  up                    do
    FastEthernet5              unassigned      YES unset  up                    do
    FastEthernet6              unassigned      YES unset  up                    do
    FastEthernet7              unassigned      YES unset  up                    do
    FastEthernet8              unassigned      YES unset  up                    do
    FastEthernet9              unassigned      YES unset  up                    up
    Vlan1                      unassigned      YES NVRAM  up                    up
    Loopback0                  172.16.1.1      YES manual up                    up
    Dialer0                    unassigned      YES manual up                    up
    NVI0  
    'show version'
    Casino#sh ver                                                                 
    Cisco IOS Software, C181X Software (C181X-ADVIPSERVICESK9-M), Version 12.4(15))
    Technical Support: http://www.cisco.com/techsupport                           
    Copyright (c) 1986-2008 by Cisco Systems, Inc.                                
    Compiled Thu 24-Jan-08 13:05 by prod_rel_team                                 
    ROM: System Bootstrap, Version 12.3(8r)YH12, RELEASE SOFTWARE (fc1)           
    Casino uptime is 52 minutes                                                   
    System returned to ROM by reload at 17:09:25 UTC Fri Jul 1 2011               
    System image file is "flash:c181x-advipservicesk9-mz.124-15.T3.bin"           
    This product contains cryptographic features and is subject to United         
    States and local country laws governing import, export, transfer and          
    use. Delivery of Cisco cryptographic products does not imply                  
    third-party authority to import, export, distribute or use encryption.        
    Importers, exporters, distributors and users are responsible for              
    compliance with U.S. and local country laws. By using this product you        
    agree to comply with applicable laws and regulations. If you are unable       
    to comply with U.S. and local laws, return this product immediately.          
    A summary of U.S. laws governing Cisco cryptographic products may be found at:
    http://www.cisco.com/wwl/export/crypto/tool/stqrg.html                        
    If you require further assistance please contact us by sending email to       
    [email protected].                                                             
    Cisco 1812 (MPC8500) processor (revision 0x400) with 118784K/12288K bytes of m.
    Processor board ID FHK120622J3, with hardware revision 0000                   
    10 FastEthernet interfaces                                                    
    1 ISDN Basic Rate interface                                                   
    31488K bytes of ATA CompactFlash (Read/Write)                                 
    Configuration register is 0x2102  
    Thanks again for your help,
    Josh

Maybe you are looking for

  • The trial of presenter doesn't seem to be installing

    Apologies in advance for length, but I thought more detail would be best when asking for help. Hi.  I am trying to install a trial of Presenter.  I have Office 2010 and am on an HP with i5 Processor.  Windows is 64 bit version.   I close everything e

  • Launch Problem

    Hi There I've recently bought an Acer Aspire 6920 Laptop and I've downloaded the trial version of Adobe Dreamweaver CS4 When I open Dreamweaver the green start up screen will open and then it will close and Dreamweaver itself won't open. All the othe

  • Opening  winmail.dat files

    How can I open winmail.dat files on a mac osx 10.4.4? Thank you Ron

  • Selection Column in SALV

    How do we create selection column like those in a table control? I'm using OO.

  • [SOLVED] brother dcp7030 & cups : error when printing

    Hello, I have a brother dcp7030 and thanks to package brother-dcp7030 in aur, I've been able to use it until yesterday. When I try to print, I get this in /var/log/cups/error_log : D [04/Jul/2010:10:36:14 +0200] cupsdSetBusyState: Printing jobs D [04