About the read() method; it returns an integer

when I us the read method (from the filereader class) to read from a file , it retyrns an ASCII representation of the character.
However , I can't display character on the screen like that (numbers). so, how can I turn them back to characters, so I can show them properly?
Another Question: How can I set the position of components inside a panel. I don't like the way the layoutmanager sets their location. I want to do it myself
Thanx

so I can show them properly?Cast to char: System.out.print((char) inputCharacter);
I want to do it myselfSet the layout manager to null and position the components with setBounds or setPosition and setSize. Good luck making it look right when the fonts and font sizes change or the container is resized.

Similar Messages

  • A question about the getProperty method defined in the Security class

    Hello Everyone!
    I would like to ask a question about the getProperty method defined in the
    Security class.
    public static String getProperty(String key) Do you know how can I exract the list of all possible keys?.
    Thanks in advance,

    I found the answer, in fact the keys are defined in the java.security file.

  • About the Reader 9.5.2 Update

    Hi Everybody:
    Yesterday, Adobe Reader successfully updated to 9.5.2 - CPSID_83708 as correctly shown on my "Add or remove programs" feature.
    However, the app still shows version 9.5.1 in the Help > About Adobe Reader 9... page, same as half of the plug-ins (whether loaded or not) shows version 9.5.1.283 instead of 9.5.2.295.
    Also, Adobe PDF Plug-In For Firefox and Netscape "9.5.1.283" in Firefox 13 finds no updates for it, and interestingly, I just found a rare "PLUGINS" folder containing this plugin for Firefox but in the IE program folder?
    Is this a known issue or a problem my side?
    Thanks in advance.

    Hi Pat:
    Not all modules are necessarily rebuilt for a security update, so some modules may still remain on the previous version.
    I wouldn't have thought of that, being that it's a "quarterly" update.
    Can you check what version the following modules have:
    C:\Program Files (x86)\Adobe\Reader 9.?\Reader\AcroRd32.dll
    C:\Program Files (x86)\Adobe\Reader 9.?\Reader\AcroRd32.exe
    C:\Program Files (x86)\Adobe\Reader 9.?\Reader\Browser\nppdf32.dll
    You're correct: They still pointing to version 9.5.1.
    If main file AcroRd32.exe is still 9.5.1, I suppose the update (contrarily to what I previously thought) did not install successfully at all.
    As it was an automatic update process and being that the installer did not show any error message but a successful completition, plus the fact that new version 9.5.2 is listed in my Programs feature - so creating a false impression of a successful installation - I would think that can be classified as a "bug"...... What would you say?
    Could it be a factor that the update installed over 9.5.1 and not over its base 9.5.0? meaning that 9.5.1 should've been uninstalled first. This is to say that the automatic mechanism does not work properly for these updates. I don't know - just wondering!
    How to troubleshoot this now?
    In Reader X they all have been updated to 10.1.4.
    I was planning to upgrade to X in the near future (before 9.x EOL) but now I may do it earlier.
    Await your advices with interest. Thanks,

  • About the tab "Method"  in definition of  activity

    In the tab "methods" in the definition of activity, what's meaning of Modal call and how to export paramaters and import parameters there.

    Try searching the SAP Help first for secondary methods in workflow. It is amazing how many answers are in there. And as an added bonus you also comply to the forum guidelines.
    Regards,
    Martin

  • About the setting method of  Instant Messaging(collabo4.01)

    Please teach me the setting method of Instant Messaging ID ( yahoo ).
    Although an icon is displayed, it will not be in an offline state.

    Hi,
    You can debug you JSPDynpage either from NWDS with the help of break points or by writing log statements in your code which will be written in defaultTrace log file.
    Check this to debug from NWDS:
    NetWeaver Portal Debugging
    Check this to write log statements:
    http://help.sap.com/saphelp_nw70/helpdata/EN/b0/003c41325fa831e10000000a1550b0/frameset.htm
    Netweaver Portal Log Configuration & Viewing (Part 3)
    Regards,
    Praveen Gudapati

  • Unable to print the array method that returns an array

    public class ReturnAtrray {
         public static void main(String[] args) {
              int[] b= {1, 3, 5};
              System.out.println(incrementArray(b,2));
         public static int[] incrementArray(int [] a, int increment)
              int[] tmp = new int[a.length];
              for(int i = 0; i <a.length; i++ )
                   tmp= tmp[i] + increment;
              return tmp;     

    You are correct: Java is always pass by value. In the case of an array it is a reference to the array that is passed by value. This means that there is a way to increment the array values "in place". As an alternative to what you are doing now consider:
    // untested
    public class ReturnAtrray {
        public static void main(String[] args)
            int[] b= {1, 3, 5};
            incrementArray(b,2);
            for(int i = 0; i < b.length; i++)
                System.out.print(b[i] + " ");
        public static void incrementArray(int [] a, int increment)
            for(int i = 0; i <a.length; i++)
                a[i] = a[i] + increment;
    }

  • I need suggestion about the way , method, or path of learning GUI

    Since there are many IDEs that are capable of developing the Java GUI quickly, one of my friend suggest me to learn GUI using code instead of drag and drop GUI component. He said when your boss ask you to fix the error/bug for the front-end part of the program, which is written in code only.
    Another situation is that when you are working with a team and your team members using code instead of these drag&drop, he said i have to adapt to using these code to write the GUI.
    Actually he has point. what do you guys think? please post your opinion.

    roadorange wrote:
    Since there are many IDEs that are capable of developing the Java GUI quickly, one of my friend suggest me to learn GUI using code instead of drag and drop GUI component. You should go through the Swing tutorial and perhaps the 2D demo that comes with the JDK. Look at the code, run the examples, step through it or whatever you want. But I personally don't think you get much (except a massive, lasting headache) from writing the code by hand.
    He said when your boss ask you to fix the error/bug for the front-end part of the program, which is written in code only.Huh?
    Another situation is that when you are working with a team and your team members using code instead of these drag&drop, he said i have to adapt to using these code to write the GUI.I'm starting to lose you here...
    Actually he has point. what do you guys think? please post your opinion.I say use the GUI tools (don't fight evolution)

  • About the read from http request, I think it is a bug in weblogic

    Hi guys,
    sorry for the previous post, I press the wrong button, I didn't finished yet.
    I have experienced a problem when I try to read from http request in a web application.
    the following is my code:
    InputStreamReader isr = new InputStreamReader(new URL("www.myhost.com").openStream(),"8859_1");
    BufferedReader bfr = new BufferedReader(isr);
    String request = "";
    while((request = bfr.readLine()) != null)
    stringGotFromServer += request;
    the problem is it always hang in there when BufferdReader reach the end.
    but in java specification, BufferedReader should reture null if reaching the
    end.
    Does anyone have any good idea for that?
    Thanks in advance.

    Hi,
    I think if you follow the instructions as given in the example you will not have any problems.
    here are the instructions below
    "This example code demonstrates one technique of handling test failures.
    If this step fails, a dialog will be displayed giving options to Break, Terminate, or Retry.
    The On Fail Post Action calls the HandleTestFailure sequence which is
    another sequence in this sequence file.
    The sequence file has the SequenceFilePreStep Callback overridden where
    the initial statue of Runstate.SequenceFailed is stored in a local variable. Create a local variable in your sequence called SequenceAlreadyFailed which is a boolen.
    To use this in your sequence file:
    1. Copy the HandleTestFailure sequence to your sequence file.
    2. For a step to use this, you
    must set the On Fail Post Action to call the
    HandleTestFailure sequence.
    3. Override the PreStepCallback.
    4. Copy the step from this example's PreStepCallback to yours.
    5. Copy the TestFailureDialog.* files to the same directory as your sequence file.

  • About the sort method of arrays

    Hi,
    I found that for primitive types such as int, float, etc., algorithm for sort is a tuned quicksort. However the algorithm for sorting an object array is a modified merge sort according to the java API. What is the purpose of using two different sorting strategy?
    Thanks.

    The language knows how to compare two ints, two doubles, etc. For Object arrays, however, it's not a simple matter of comparing two reference values as ints or longs. We're not comparing the references. We have to compare the objects, according to the class's compareTo() method (if it implements Comparable) or a provided Comparator. The size of an int is known, fixed, and small. The size of an object is unknown, variable, and essentially unbounded. I don't know for sure that that difference is what drove the different approaches, but it is a significant difference, and mergesort is better suited to use cases where we can't fit the entire array into memory at one time. It seems reasonable that we'd get better locality of reference (fewer cache misses, less need to page) with an array of ints than with an array of objects.
    Edited by: jverd on Mar 18, 2011 3:16 AM

  • About the setMode method of Camera

    Quoted from here:
    Sets the camera capture mode to the native mode that best meets the  specified requirements. If the camera does not have a native mode that  matches all the parameters you pass, Flash Player selects a capture mode  that most closely synthesizes the requested  mode. This manipulation may involve cropping the image and dropping  frames.
    Does it mean that the frames captured is not necessarily the same as required by setMode(width:int, height:int, fps:Number, favorArea:Boolean = true) ? The actual frame captured may be either wider/narrower,higher/lower in size and have higher/lower frequency than required ,is this true?

    It's going to depend on the camera and whether it supports what you have set. Nowadays drivers are pretty good and support all kinds of sizes and framerates. The flash will do it's best to give you what you want, but it all matters on whether or not the driver for the cam will support it.
    Graeme Bull
    www.fmsguru.com

  • What is the proper way to use the write method?

    What is the proper way to use the OutputStreams write method? I know the flush() method is automatically called after the write but i cant seem to get any output
    to a file. The char array contains characters and upon completion of the for loop the contents of the array is printed out, so there is actually data in the array. But write dosnt seem to do squat no matter what i seem to do. Any suggestions?
    import java.io.*;
    public class X{
    public static void main(String[] args){
    try{      
    FileReader fis = new FileReader("C:\\Java\\Test.txt"); //read chars
    FileWriter fw = new FileWriter("C:\\Java\\Test1.txt"); //read chars
    File f = new File("C:\\Java\\Test.txt");
    char[] charsRead = new char[(int)f.length()];
    while(true){
    int i = fis.read(charsRead);
    if(i == -1) break;
    // fw.write(charsRead); this wont work
    // but there is infact chars in the char Array?
    for(int i = 0; i < charsRead.length -1 ; ++i){
    System.out.print(charRead);
    }catch(Exception e){System.err.println(e);}

    Sorry to have to tell you this guys but all of the above are broken.
    First of all... you should all take a good look at what the read() method actually does.
    http://java.sun.com/j2se/1.3/docs/api/java/io/InputStream.html#read(byte[], int, int)
    Pay special attension to this paragraph:
    Reads up to len[i] bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len[i] bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer.
    In other words... when you use read() and you request say 1024 bytes, you are not guaranteed to get that many bytes. You may get less. You may even get none at all.
    Supposing you want to read length bytes from a stream into a byte array, here is how you do it.int bytesRead = 0;
    int readLast = 0;
    byte[] array = new byte[length];
    while(readLast != -1 && bytesRead < length){
      readLast = inputStream.read(array, bytesRead, length - bytesRead);
      if(readLast != -1){
        bytesRead += readLast;
    }And then the matter of write()...
    http://java.sun.com/j2se/1.3/docs/api/java/io/OutputStream.html#write(byte[])
    write(byte[] b) will always attempt to write b.length bytes, no matter how many bytes you actually filled it with. All you C/C++ converts... forget all about null terminated arrays. That doesn't exist here. Even if you only read 2 bytes into a 1024 byte array, write() will output 1024 bytes if you pass that array to it.
    You need to keep track of how many bytes you actually filled the array with and if that number is less than the size of the array you'll need pass this as an argument.
    I'll make another post about this... once and for all.
    /Michael

  • ByteBuffer: how come the abstract methods work?

    I am confused about the abstract methods in ByteBuffer class. Many of the methods in that class are declared abstract but yet I am able to use them without a problem.
    For example, put(byte b) is declared abstract in the java docs. But I am able to use that method ( I did not have to extend ByteBuffer and implement this method). I know I must be missing something here...any help would be appreciated.
    thanks

    Those responses should certainly do the trick. But I love hearing myself type, so here's an example:abstract class Fred
         public abstract void hiThere();
    class SubFred extends Fred
         public void hiThere() { println("Greetings Professor Falken"); }
    }Somewhere some method says it returns an object of type Fred. To do this they might (as far as you know) create an instance of SubFred and return that to you. SubFred is of type Fred. Your code doesn't know or care (usually) what the ACTUAL class is, as long as it matches what you expect Fred to be from the documentation.

  • About the class File

    Hi everybody, I need your help with this problem...
    I'm just trying to delete some files on this way:
    private void vectorManager(Vector vector) {
    File file = null;
    RandomAccessFile raf = null;
    try {          
    for (int i = 0; i < vector.size(); i ++) {               
    file = (File)vector.elementAt(i);
    raf = new RandomAccessFile(file, "r");
    //this method just return an integer after its action
    //(the method just save the file in some place)
    switch (fileManager(raf, file.getName())) {
    case 0: {
    System.out.println("[ERROR]The file ==> " + file.getName() + " can't be saved");
    break;
    case 1: {
    System.out.println("The File ==> " + file.getName() + " has been successfully saved");
    //Now I don't need this file anymore
    if (file.delete()) {
    System.out.println("File deleted");
    } else {
    System.out.println("File NOT deleted");
    //I always see this only message and the file is not removed from my hard disk
    break;                    
    } catch(Exception e) {
    System.out.println("[ERROR] ==> " + e);
    Is there another way to delete a file?, I know that is a very rare case, but i hope that your interest to help me, be enough to resolve my doubts, thanks!.

    raf = new RandomAccessFile(file, "r");stream may be open as mentioned previously
    instead of
    if (file.delete()) {
    System.out.println("File deleted");
    try to catch this exception and it will tell you particulars about the failed deletion of the file
    public boolean delete()
    Throws:
    SecurityException - If a security manager exists and its SecurityManager.checkDelete(java.lang.String) method denies delete access to the file

  • The problem about the signal of JNI

    Hello,
    When the system (it creates by the C language) created here is operated on Solaris and javaVM is operated using a JNI, the phenomenon which the core file outputs within the JIT compiler of java (libsunwjit.so) has occurred.
    Although it had generated twice until now, since it had collided with the signal which the signal has generated in one of the another threads, and it uses internally by JavaVM from the contents of a core file when it generated first, it had generated.
    However, although the core file was investigated when it generated at the 2nd times, there was no trace that another thread generated the signal.
    Is there any case where collide with the signal currently used by JavaVM, and also a signal is generated in a JIT compiler?
    What thing has an obstacle used as the factor which a JIT compiler makes have generated the signal in the past again?
    Please give me the reply to the above-mentioned question for a cause elucidation.
    As appending data, the contents which referred to the core file are described below.
    (gdb) thread 1
    [Switching to thread 1 (LWP    163        )]
    #0 0xfe359d88 in __sigprocmask () from /usr/lib/libthread.so.1
    #1 0xfe34eb34 in __sigredirect () from /usr/lib/libthread.so.1
    #2 0xfe351a10 in thrpkill_unlocked () from /usr/lib/libthread.so.1
    #3 0xfe239470 in abort () from /usr/lib/libc.so.1
    #4 0xfb49353c in panicHandler ()
    from /opt/fujitsu/jasmine/JasEMedia/jre/lib/sparc/classic/libjvm.so
    #5 0xfb798084 in intrDispatchMD ()
    from /opt/fujitsu/jasmine/JasEMedia/jre/lib/sparc/native_threads/libhpi.so
    #6 0xfe359348 in __libthread_segvhdlr () from /usr/lib/libthread.so.1
    #7 0xfe35bdf0 in __sighndlr () from /usr/lib/libthread.so.1
    #8 0xfe3586f8 in ?? () from /usr/lib/libthread.so.1
    #9 0xfb3bd8bc in JITPerformDynamicPatch ()
    from /opt/fujitsu/jasmine/JasEMedia/jre/lib/sparc/libsunwjit.so
    #10 0xfb3de848 in JITResolveConstPoolEntry ()
    from /opt/fujitsu/jasmine/JasEMedia/jre/lib/sparc/libsunwjit.so
    #11 0xb945908 in ?? ()
    #12 0xc5054e4 in ?? ()
    #13 0xe2974c in ?? ()
    #14 0x851b75c in ?? ()
    #15 0x7c3841c in ?? ()
    #16 0xb917560 in ?? ()
    #17 0x8a9b6d4 in ?? ()
    #18 0xb8e18e0 in ?? ()
    #19 0x71377d8 in ?? ()
    #20 0x7137784 in ?? ()
    #21 0x7d7d7f4 in ?? ()
    #22 0xc67c4b0 in ?? ()
    #23 0x913998c in ?? ()
    #24 0xb2bf58 in ?? ()
    #25 0xc51a854 in ?? ()
    #26 0x8794c7c in ?? ()
    #27 0xfb3de980 in JIT_INVOKER_MARKER ()
    from /opt/fujitsu/jasmine/JasEMedia/jre/lib/sparc/libsunwjit.so
    #28 0xfb494cec in notJavaInvocation ()
    from /opt/fujitsu/jasmine/JasEMedia/jre/lib/sparc/classic/libjvm.so
    #29 0xfb457674 in jni_Invoke ()
    from /opt/fujitsu/jasmine/JasEMedia/jre/lib/sparc/classic/libjvm.so
    #30 0xfb45930c in jni_CallVoidMethod ()
    from /opt/fujitsu/jasmine/JasEMedia/jre/lib/sparc/classic/libjvm.so
    #31 0xfbee0d7c in ChartJem_Generate ()
    from /opt/fujitsu/jasmine/EMImageChart/lib/GKM0JEMC.so
    #32 0xfb7630a4 in ?? ()
    from /opt/fujitsu/jasmine/data/default/methods/JasEMedia/lib043C.so.2.0
    #33 0xff2b106c in odb_OmsPcExec () from /opt/fujitsu/jasmine/lib/libjas.so
    Please contact me, if the core file is required. Separately, I will send.
    In that case, also about the transmission method, please unite and contact me.
    The system configuration is as follows.
    Operation System:SOLARIS(7)R00081
    Java version:1.2.2 Classic VM (build JDK-1.2.2-W, green threads, sunwjit)
    I'm hoping someone can help me out.
    Thanks!

    After that, a problem is not solved. Would you teach, if there is the method of something saying?

  • Buffered Reader read() method

    I'm trying to read a data file using the BufferedReader.read() method. Where the file is valid data I cast to a char and build up a string which then gets written to a flat file.
    Some of the bytes I need to read are pointers to a position in another file. These I want to read as integers, and I would expect to be able to use the value returned by the read() method directly.
    However I have a problem when the pointer byte has a value from hex 80 to 99 (I can see these using 'hex' on a LINUX system). The values returned are not what I would expect eg. where I would expect 128, I get 8364, expecting 130 I get 8218 and 131, I get 402.
    Above 159, things appear to be working as I would expect.
    Can anyone explain please
    Thanks,
    Martin

    BufferedReader should only be used to read character data. The value you get from the read method is not the value that was in the file. BufferedReader simply reads character data from an underlying Reader. Your underlying reader is probably an InputStreamReader or a FileReader. Both of those readers perform a transformation from the byte data to the characters using some character encoding. If you want the actual values, you must read them from the InputStream directly or use a DataInputStream

Maybe you are looking for

  • Error message log in session method of ALV report,

    In ALV report please let me know: 1) In session method: where all error messages are stored,I know that error messages are stored in a log file, so please tell me where is it stored. 2)transaction method: How to handle error messages in transaction m

  • Problem with Two tab canvases in a form

    Hi Experts, I am working on Oracle forms 10g (OS: Windows7) from last 1 year. I have got a requirement to create a form with one tab canvas CAN_TAB (with 2 tab pages) in main page and a pop up tab canvas ASN_SPLIT_TAB(with 2 tab pages). Now the probl

  • Database is active or not from OS level

    Dear all, How you will check whether database is active or not from OS level? Regards Ganesh

  • Why does mac not accept blank dvd

    My mac book pro keeps ejecting balnk dvd. even when accepted icon for dvd not showing on desktop. please help

  • Keyboard Shortcut to cycle windows?

    I just wipped my iBook and reinstalled X.4, but now one of the shortcuts I use all the time isn't working. <Apple> ~ usually cycles through open windows of an applicaiton, but now it just beeps at me when I do it. Was there a setting I changed origin