How to Read from Standard Input?

Hi,
I am new to Java. Been reading the tutorial, but still unable to find How to read from standard Input.
Can anyone help? Thanks.
Here is my simple & error code:
public class test
public static void main(String[] args)
char filename[];
int i=0;
System.out.print("Type in a filename to read: ");
while ( System.in(filename) != -1 )
i++;
System.out.print(filename);
RP

import java.io.*;
public class forum{
     public static void main(String args[]) throws IOException
InputStreamReader is = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(is);
String input = "";
do
try
System.out.println("Enter command: ");
input = br.readLine();
catch ( IOException io ) {}
} while (!input.equals("exit"));
[code\]
package to import is java.io.*;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • BR0255W Cannot read from standard input during a dbverify

    Hello,
    I am using:
    BRBACKUP 7.20 (13)
    SunOS 5.10 Generic_144488-06 sun4u
    701 SAPSR3
    Oracle 11.2.0,.2
    brbackup -w only_dbv -t online -c -u / -e 16
    It generally runs ok, but today I got:
    BR0280I BRBACKUP time stamp: 2011-04-20 11.20.47
    BR0063I 5 of 11 files processed - 14900.039 of 73640.086 MB done
    BR0204I Percentage done: 20.23%, estimated end time: 12:45
    BR0001I **********________________________________________
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.44
    BR0281W BRBACKUP interrupted by signal 2
    BR0269W Wait situation interrupted - probably cannot continue
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.44
    BR0256I Enter 'c[ont]' to continue, 's[top]' to cancel BRBACKUP:
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.45
    BR0251W Function gets() failed at location BrConfEnter-1
    BR0253W errno 5: I/O error
    BR0255W Cannot read from standard input
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.45
    BR0261E BRBACKUP cancelled by signal 2
    BR0056I End of database backup: befrzrsn.dbv 2011-04-20 11.21.46
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.49
    BR0054I BRBACKUP terminated with errors
    1. Would you know what yould cause this Cannot read from standard input?
    2. Is there a maximum number of process that can/should be passed to -e option?
    Thanks in advance for your answer.

    Hello Benoît,
    if I understood correctly, your brbackup was not started interactively, but in background, by crontab or DB13 or something like that.
    As you perhaps know, signal 2 usually means that the process was interrupted by a ctrl-C from keyboard. This should not happen for a background process.
    It could be that someone played around with kill command.
    I rather suspect some resource bottleneck.
    Could you please check Unix kernel parameters (or whatever their equivalent in SunOS is called - I am not familiar with it).
    Or any suspicious entries in Unix log files?
    regards

  • BRGUI: Connect WindowsXP to AIX: BR0255E Cannot read from standard input

    Hi,
    I configure brgui.properties and seam everything ok:
    brgui.remote-0=D11 (rsh aixd11 -l orad11)
    It connect to server, but in the footer of 2nd BRGUI screen (after login screen) it appears "Error: Cannot read from standard input" in red.
    And some seconds later the application closes.
    I see the log and it has the following:
    BR0651I BRTOOLS 7.00 (16)
    BR0280I BRTOOLS time stamp: 2008-04-15 16.30.10
    BR0656I Choice menu 1 - please make a selection
    BR*Tools main menu
    1 = Instance management
    2 - Space management
    3 - Segment management
    4 - Backup and database copy
    5 - Restore and recovery
    6 - Check and verification
    7 - Database statistics
    8 - Additional functions
    9 - Exit program
    Standard keys: c - cont, b - back, s - stop, r - refr, h - help
    BR0662I Enter your choice:
    BR0280I BRTOOLS time stamp: 2008-04-15 16.30.10
    BR0255E Cannot read from standard input
    BR0280I BRTOOLS time stamp: 2008-04-15 16.30.10
    BR0654I BRTOOLS terminated with errors
    Can anybody help? Maybe is it related with AIX files authorizations?
    Thanks a lot!
    Rui

    Hi Rui,
    Please take note on the following important points.
    When you use the remote option, ensure that the environment on the
    remote host is fully configured to use the BR*Tools, and that the remoteuser has the relevant database rights. You should also ensure that the
    relevant environment files are actually called up during the remote
    access.
    and
    In some cases, BrGui does not work with the Remote Shell rsh from from
    Microsoft Windows XP Service Pack 2 or Microsoft Windows Server 2003
    Service Pack 1. See Microsoft Support Article ID 896336. Microsoft
    offers a hotfix for this purpose. As a workaround, use the rsh from the
    previous Service Pack. This is located in the uninstall directory after
    the Service Pack has been installed. You can also enter the complete
    path in the relevant remote call.
    Hope the above information helps.

  • How to read from UDP ??

    Hello,
       I have a device which sends MPEG2 multicast udp live stream, I can read it from udp://@236.1.1.14:34000 for instance. Next it is transcoded with vlc :
    cvlc -vvv udp://@236.1.1.14:34000 --sout \
            "#transcode{venc=x264{keyint=60,profile=baseline,level=3.0,nocabac},vcodec=x264,vb=250,sc ale=0.6,acodec=mp4a,ab=96,channels=2,samplerate=48000}:rtp{dst=127.0.0.1,port=10013,mux=ts }" 2>1 > /dev/null &
    My question is how to read from udp://@127.0.0.1:10013 using FMS and send it to flash clients ?
    Thank you

    Hi Nikhil,
        Thank you for the response. But what kind of streams can I feed into FMS input ? VLC supports other types of output, HTTP for example

  • How to read from 4 serial ports

    Hi
    Does anyone know how to read from 4 COM ports with only 2 interupts? I can
    manage it by using Close serial driver.vi, however this makes the amount of
    allocated memory by Labview increase throughout my experiment and thereby
    slows down the computer. I use Labview 4.0.1 on Win95.
    Regards
    Frede Lei

    Hi,
    Thanks for the reply however I could able to write the PCR to read one variable without wagetype. My question is, I have 6 variables in VAR table and now I want to read all the variable and based on the variable I need to create the 6 wagetype each for each variable.
    I know to create the wagetype with one variable.
    ZSSB CCE : restore 7SSB wage types paid separately in RT       
            AMT=& VSSB Set                                         
            AMT?0      Comparison                                  
                ADDWTI7SSB IT   Input table                        
              =                                                    
    However, how I could create the only 1 PCR for 6 variable?
    regards,
    Saurabh Garg

  • How to read from text file?

    I would like to read data (frequencies) already written in a text file. I will need read these frequencies one at a time to set the function generator (as part of my data acquisition application), acquire data that is in turn written to a file and then go back and read the next frequency from the file to repeat the process again. I also have another idea of doing the same, which is read all the frequencies from the text file and populate a table and a frequency value is picked from the table each time to go through the process mentioned above.
    Can anyone suggest the following: (1) How to read from a text file, (2) What could be the most efficient way of solving my above problem.
    I am a new LabVIEW user and any help will be appreciated.

    Hi Research,
    Depending on the format of the data file, there are a few options for reading it.  If it is tab delimited, you may want to use the Read from SpreadSheet File VI which will read the file into an Array.  You can then use the Index Array VI to pull out individual entries.  If the files is ASCII but not tab delimited, you could use the regular Open File and Read File VIs.  You can either read the file out piece by piece, or read the entire file into a string and then use the Match Pattern VI to parse out the different elements (there are actually many ways to do this - check out the Strings subpalette). 
    Since you're new to LabVIEW, you may want to check out these resources:
    Three Hour Introduction to LabVIEW
    Six Hour Introduction to LabVIEW
    Getting Started with LabVIEW
    I hope this helps!  Let us know if you have more questions,
    Megan B.
    National Instruments

  • How to read from properties file

    Hi,
    I am using JSR 168.
    while creating a new portlet, a folder gets created with the name as "portlet". Under which is resource package and <PortletName>Bundle.java.
    pls tell me how to read from .properties file.
    waiting eagerly for some reply
    Thanks & Regards,
    HP
    Edited by: user9003827 on Apr 13, 2010 3:42 AM

    I think i have mixed it up :)
    I have looked at it again and believe you are using regular JSP portlets.
    Can you tell what you want to achieve by reading .properties file. Are you meaning the preferences of the portlet or what exactly are you trying to do?
    Reading propertie files is easy:
    // Read properties file.
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream("filename.properties"));
        String myKey = properties.getProperty("yourKey");
    } catch (IOException e) {
    }Edited by: Yannick.O on 13-Apr-2010 05:52

  • How to read from file just the 2nd line onwards?

    hi guys can anyone help me?
    how to read from the file if the file was like this
    2 2
    2 1
    1 3
    and i want to get the 2 1 ,just the 2nd line and the 3rd line?
    i tried using the string tokenizer but it kept saying
    no such element
    i tried this code:
    StringTokenizer cols = new StringTokenizer(s," ");
         temp =  (String) (cols.nextElement());
         num_rows = Integer.parseInt(temp);
         temp = (String) (cols.nextElement());
         num_cols = Integer.parseInt(temp);
         matrix = new int [num_rows][num_cols];
         // to add all the values in the data file into an array                         
         while ( s!= null ) {
         StringTokenizer st1 = new StringTokenizer (s);
               while (st1.hasMoreTokens()){
                     for (i=0; i<num_rows; i++){
                          for (j=0; j<num_cols; j++)
                             matrix[i][j] = Integer.parseInt
                                ( st1.nextToken());
                } // whilecan anyone please help me?
    thanks

    This will read the file witout the first line:
    import java.io.*;
    import java.util.*;
    public class Read2
    public static void main (String[] args)
         try
              FileReader     file = new FileReader("f.txt");
              BufferedReader buff = new BufferedReader(file);
              String         line  = buff.readLine();
              while (line != null)
                   line = buff.readLine();
                   System.out.println(line);
              buff.close();
         catch(IOException e)
              System.out.println("IO Error");
    }       Noah

  • How to read from a file line by line

    Hi
    I am new to using LabView and was wondering how I could read data from a text file one line at a time and display this data one line at a time as well. I tried looking through the Reading from Text File . vi example but that just seems to be reading and displaying everything together.
    Thanks
    -Karan

    Hi
    My aim is to read text line by line and to then go ahead and display the last 8 reaad lines of code to give the impression of text falling down a screen. I tested the first while loop and that seemed to work fine. However, when I encounter an EOF, I would like the text already read to keep making its way down the screen and keep inputting NULL characters into the array to simulate the effect of the text falling down the screen which is why I created the second while loop. I tried to input the NULL characters using a box for ENUM constants. However, I kept getting an error saying the data types do not match. What would I need to do? For the display I plan on putting indicators next to the 8 places where the text would be stored which I have not done so far.
    I am also attaching a copy of the error.
    Thanks
    -Karan
    Attachments:
    DisplayText.vi ‏40 KB
    Error.JPG ‏89 KB
    PictureOfBlock.JPG ‏120 KB

  • How to read from a file

    hello friends i m a newbie in java n as i m self studying java, i got stuck on the input streams.sir could u please help me how to read a file named test.txt from following code.
    import java.io.*;
    class ShowFile {
    public static void main(String args[])
    throws IOException
    int i;
    FileInputStream fin;
    try {
    fin = new FileInputStream(args[0]);
    } catch(FileNotFoundException exc) {
    System.out.println("File Not Found");
    return;
    } catch(ArrayIndexOutOfBoundsException exc) {
    System.out.println("Usage: ShowFile File");
    return;
    // read bytes until EOF is encountered
    do {
    i = fin.read();
    if(i != -1) System.out.print((char) i);
    } while(i != -1);
    fin.close();
    }

    sir i heartly appericiate ur quick response the problem in above code is that i have copied the above code from a book which i m reading but it hasn't included any file for reference whch i can test the code upon ie when it is being compiled n runned the no file found error is indicated

  • How to read from a HPIB instrument using GPIB software?

    How Can I read from a HPIB instrument using GPIB software and library functions in Visual Basic Environment? In HPIB we do not have to send query first but in GPIB we do? Although writing and sending a command is to a HPIB instrument is pretty much the same as a GPIB instrument. Any help or suggestion?
    Thanks in Advance
    Shazaduh

    HI,
    HPIB and GPIB are the same thing at a low level in terms of instrument communication. They are both compliant with the IEEE 488.2 standard.
    The difference is the driver you have to use. Each manuafacturer has to develop a driver to control the interface ont he host. For National Instruments interfaces you use NI-488.2 (which you refer to GPIB functions). For HP interfaces you need to use the SICL library. For information using this library in Visual Basic you'll have to look at the SICL documentation.
    You can also use VISA (HP-VISA) which would allow you use NI interfaces or other buses in the future.
    Hope this helps.
    DiegoF
    National Instruments.

  • How to read 2 analog inputs with VISA

    Hello everyone! I want to read two analog inputs using VISA serial communication from the arduino.  I'm currently able to read one of the input but how do I read two analog inputs on labview?

    Hi lamela,
    again I have to ask: HOW does the string look like? Is it so hard to provide an exact example of your received string???
    I think the string is showing one value from the two inputs
    Are you sure or are you guessing? How can we tell what you might "think" when you aren't able to provide examples?
    You wrote you send values from the Arduino using the command "println(value1, value2)", but now you "think" you only receive ""value1" in LabVIEW?
    Get your data communications clear! (And learn to provide meaningful examples!)
    Edit after your edit:
    my code to serial print two inputs: Serial.println(Voltage, Current);
    Even if I print separately: Serial.println(Voltage);
                                                 Serial.println(Current);
    The first command is completely different then the second part! In the first you should receive two values in one line, in the 2nd one you receive one value per line: You need to adapt your string parsing to these strings!
    Again: send both values in one line. Use the LF as termchar. Separate the values by some separator char like comma. Check the received string for validity. Use some error checking in your VI.

  • How to read from and write into the same file from multiple threads?

    I need to read from and write into a same file multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

    Assuming you are using RandomAccessFile, you can use the locking functionality in the Java NIO library to lock sections of a file that you are reading/writing from each thread (or process).
    If you can't use NIO, and all your threads are in the same application, you can create your own in-process locking mechanism that each thread uses prior to accessing the file. That would take some development, and the OS already has the capability, so using NIO is the best way to go if you can use JDK 1.4 or higher.
    - K
    I need to read from and write into a same file
    multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

  • How to read from a certain location is a file?

    hi! i am new to programing and i have a problems abt reading from a file. i have write the following to a file using FmtFile :
    10 (a numbers)
    name,phone,product (some strings)
    9 (a numbers)
    when i user ScanFile to read the second number(9 in the above example), i got a wrong value. the command i use is:
    ScanFile (filehandle, "%d", &number1);
    ScanFile (filehandle, "%s[t44]%s[t44]%s",name, phone product);
    ScanFile (filehandle, "%d", &number2);
    number1 and number 2 are integers and name, phone and product are char arrays.
    can anyone tell me where have i gone wrong? or maybe someone can tell me how can i read the 2nd number without reading the 1st number
    and the strings.

    Let's look at your file: if I correctly interpret your question, one row in it should like like this:
    10,name,phone,product,9
    In this case you could use the following formatting string to read all data from the string:
    "%d[x]%s[xt44]%s[xt44]%s[xt44]%d"
    [x] means to discard terminator, in order to read from strings, for example, "name" and not "name,". It's important in this case to put ALL field separators.
    Maybe your problem is that in the file you don't have separators between strings and numbers: in this case the last "%s" should read the '9' inside the last string and the subsequent "%d" matches with incorrect area in the file (end-of-line or next row).
    Hope this help
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How to read from txt file that has words in between?

    Hi all,
    I am using Labview 8.2.
    I would like to read from a text file.  I have data (after each time it is has averaged over 100 waveforms) repeatedly stored on to the file.  The idea is to further improve SNR in post processing by again averaging the data (that has been averaged over the 100 waveforms).  
    I can get LabView  to save the data repeatedly into the file, so it keeps getting appended.
    The problem is to read the data in labview so I can now again average it.  The problem is the labview seperates the sets of data with the following:
    " Channels    1    
    Samples    9925    
    Date    2008/10/28    
    Time    17:16:11.638363    
    X_Dimension    Time    
    X0    -3.0125000000000013E-3    
    Delta_X    2.500000E-6    
    ***End_of_Header***        "
    So When I read it, it only sees the first set of data.
    Can someone please tell me how to read all the sets of data in labview?
    I have attached the file I want to read "acquiredwaveform.txt"  and the basic VI (really basic btw) to read the file.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    ReadFileAndAverage.vi ‏48 KB
    acquiredWaveform.txt ‏605 KB

    Thanks again DFGray for the comments. 
    After the correlations to find the peak positions, i just take the max value.  And you are right the accuracy is limited by the number of  samples per cycle.  Perhaps it would be clearer if you see the code.
    1) Basically I get a signal on the up and downslope of the sine wave.  On the down slope however the signal is negative, i.e. its is flipped.  So before I shift and average...I 'cut' the waveform into 4 (when cycles per buffer = 2, then I get 4 signals, 2 on the up slope and 2 on down slope) bits.  Counting from one, I flip the even number, cut it, and but an array of waveforms which is then sent to be convolved and shifted.
    2) Array of waveforms are stored to be phased shifted (Convolve and shift vi) and averaged (entire averaging vi which uses the convolve and shift vi as a sub vi). 
    * Phase shifting doesn't work when I cut and put it together (So something is wrong in cut waveform vi) 
    * Also if it isn't too time consuming could you give me an example of interpolating and shifting thing.
    * Also if you have any comments regarding the following VIs please let me know.  
    Thanks 
    Attached is:
    1) Cut waveform vi
    2) Convolve and shift
    3) Entire averaging 
    Attachments:
    SubVICutWaveforms.vi ‏37 KB
    SubVIConvolveShift.vi ‏30 KB
    SubVIEntireAveraging2.vi ‏43 KB

Maybe you are looking for