Read from file

Hi everyone.
I've been trying finish my "sudoku" game and i really need some help. So as so far i can save my game to the file but i'm having problem with load them. So maybe i shall above my code:
The first method is call when i press load button. (mean method)
     private void loadSudokuFromFile() {
          String fileName = fileNameT.getText();
          if (fileName.length() <= 0) {
               fileName = DEFAULT_FILE_NAME;
               fileNameT.setText("" + DEFAULT_FILE_NAME);
          System.out.println("Reading: " + fileName);
                readSudokuFromFile(fileName);
          lastSavedGridOfValues = createAGridCopy(currentGridOfValues);
          displayGridValues(numberFields, currentGridOfValues, lastSavedGridOfValues);
     }This is a method that read string line by line:
private int[][] readSudokuFromFile(String filename) {
     try {
          DataInputStream dataIn = new DataInputStream(new FileInputStream(filename));
          BufferedReader in = new BufferedReader(new InputStreamReader(dataIn));
          String line;
          while ( (line = in.readLine()) != null ) { // Read Lines
               // CHECK LINE FOR DATA
               if ( (line.length() == 0 || !line.substring(0, 1).equals("|")) || !line.substring(0, 1).equals(" "))
                    continue;
               System.out.println("Data: " + line);
          in.close();
    } catch (Exception _e){//Catch exception if any
      System.err.println("Error: " + _e.getMessage());
    return null;
}I think i need something that would be scann my string and cought only numbers . Somewhere i want to process lines of string from the file. Maybe i need another method ?
The output from my saved game is:
| - 4 - | 7 - - | 2 - 1 |
| - - - | - - - | - 8 9 |
| 1 - 8 | - 5 - | 4 - - |
|-----------------------
| - 1 6 | - - 7 | 8 - - |
| - 4 - | - - - | 1 - 6 |
| 2 - 9 | - - - | - - 5 |
|-----------------------
| 4 5 - | 6 3 2 | - - - |
| - - - | - 1 4 | 9 - 3 |
| - 7 - | - - - | - 1 - |
|-----------------------So there is space between hyphen and numbers . I need only load this numbers the array is 2 dimmensional [9][9]
Thx for any help.

Snowboarder wrote:
because this is my one of the many tasks from school! so it's not up to me.And the format of the file is fixed, you can't change it? That's silly, but ok.
Ok so if i go like this:
import java.io.File;
import java.util.Arrays;
import java.util.Scanner;
private int[][] readFromFile(Scanner file){
Scanner file = new Scanner(new File("ScannerDemo.java"));
while(file.hasNextLine()) {
String line = file.nextLine();
String[] tokens = line.split("\\s+");
System.out.println("word: "+Arrays.toString(tokens));
}so i need anothe method where i could parse my string into integer and use nested for loop to print my data. Am i thinking correctly?
if yes how could i call my "readFromFile" method to another that would execute my tokens parsed into integer?
ThxI don't understand what your are asking.
Did your run my code? Do you understand what it does? If so, surely you can change it so that it suits your needs. If not, please ask a specific question and post your best effort here.

Similar Messages

  • Error reading from file glibc-2.5-24.i686.rpm RHEL 5 Setup stuck at 80%

    Hi, I am installing Oracle 10g on RHEL 5 (Red Hat Enterprise Linux 5) machine I am facing two problems
    1) while installing the rpm packages the following package gave an error
    Error reading from file glibc-2.5-24.i686.rpm
    2) I still gave a try to runInstaller command the installer opened but was stuck at 80%
    I have 3 GB ram and 320GB hard drive I am not sure what to put in the swap memory and other settings i blindly followed instructions given here
    http://www.oracle-base.com/articles/10g/OracleDB10gR2InstallationOnRHEL5.php
    What could be the problem where do I find the error log if its created
    Please help me
    Thanks
    Edited by: 891355 on Nov 6, 2011 12:06 PM

    I found the installActions file in the installer folder and I think this could be the problem
    INFO: The 'shiphomeproperties.xml' file is missing from shiphome location '/home/oracle/Desktop/database/install/../stage/products.xml.' Add this file to the 'Disk1/stage' directory of the shiphome.
    though I am attaching the log file for more details do you think the installer is corrupt :(
    InstallActions log file ==> http://www.mediafire.com/?nh7mx7bxqht9ovu
    Edited by: 891355 on Nov 6, 2011 1:35 PM

  • [Error] Microsoft SQL Server 2008 Setup. Error reading from file msdbdata.mdf

    Hi all
    I'm trying to install SQL 2008 Express on my Computer: Hp compact DX7300 Slim tower.
    and get this error:
    TITLE: Microsoft SQL Server 2008 Setup
    The following error has occurred:Error reading from file d:\8268cd7b247d294de359c9\x86\setup\sql_engine_core_inst_msi\PFiles\SqlServr\MSSQL.X\MSSQL\Binn\Template\msdbdata.mdf.  Verify that the file exists and that you can access it.
    Click 'Retry' to retry the failed action, or click 'Cancel' to cancel this action and continue setup.
    For help, click: http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=10.0.1823.0&EvtType=0xF45F6601%25401201%25401
    Log file
    Overall summary:
      Final result:                  SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup.
      Exit code (Decimal):           -2068643839
      Exit facility code:            1203
      Exit error code:               1
      Exit message:                  SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup.
      Start time:                    2014-12-09 23:22:03
      End time:                      2014-12-09 23:40:28
      Requested action:              Install
      Log with failure:              C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20141209_232121\sql_engine_core_inst_Cpu32_1.log
      Exception help link:           http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=10.0.1823.0
    Machine Properties:
      Machine name:                  VISTA-PC
      Machine processor count:       2
      OS version:                    Windows Vista
      OS service pack:               Service Pack 1
      OS region:                     United States
      OS language:                   English (United States)
      OS architecture:               x86
      Process architecture:          32 Bit
      OS clustered:                  No
    Product features discovered:
      Product              Instance             Instance ID                    Feature                
                     Language             Edition              Version         Clustered 
    Package properties:
      Description:                   SQL Server Database Services 2008
      SQLProductFamilyCode:          {628F8F38-600E-493D-9946-F4178F20A8A9}
      ProductName:                   SQL2008
      Type:                          RTM
      Version:                       10
      SPLevel:                       0
      Installation location:         d:\8268cd7b247d294de359c9\x86\setup\
      Installation edition:          EXPRESS
    User Input Settings:
      ACTION:                        Install
      ADDCURRENTUSERASSQLADMIN:      False
      AGTSVCACCOUNT:                 NT AUTHORITY\NETWORK SERVICE
      AGTSVCPASSWORD:                *****
      AGTSVCSTARTUPTYPE:             Disabled
      ASBACKUPDIR:                   Backup
      ASCOLLATION:                   Latin1_General_CI_AS
      ASCONFIGDIR:                   Config
      ASDATADIR:                     Data
      ASDOMAINGROUP:                 <empty>
      ASLOGDIR:                      Log
      ASPROVIDERMSOLAP:              1
      ASSVCACCOUNT:                  <empty>
      ASSVCPASSWORD:                 *****
      ASSVCSTARTUPTYPE:              Automatic
      ASSYSADMINACCOUNTS:            <empty>
      ASTEMPDIR:                     Temp
      BROWSERSVCSTARTUPTYPE:         Disabled
      CONFIGURATIONFILE:             C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20141209_232121\ConfigurationFile.ini
      ENABLERANU:                    True
      ERRORREPORTING:                False
      FEATURES:                      SQLENGINE,REPLICATION
      FILESTREAMLEVEL:               0
      FILESTREAMSHARENAME:           <empty>
      FTSVCACCOUNT:                  <empty>
      FTSVCPASSWORD:                 *****
      HELP:                          False
      INDICATEPROGRESS:              False
      INSTALLSHAREDDIR:              C:\Program Files\Microsoft SQL Server\
      INSTALLSHAREDWOWDIR:           C:\Program Files\Microsoft SQL Server\
      INSTALLSQLDATADIR:             <empty>
      INSTANCEDIR:                   C:\Program Files\Microsoft SQL Server\
      INSTANCEID:                    SQLExpress
      INSTANCENAME:                  SQLEXPRESS
      ISSVCACCOUNT:                  NT AUTHORITY\NetworkService
      ISSVCPASSWORD:                 *****
      ISSVCSTARTUPTYPE:              Automatic
      MEDIASOURCE:                   d:\8268cd7b247d294de359c9\
      NPENABLED:                     0
      PID:                           *****
      QUIET:                         False
      QUIETSIMPLE:                   False
      RSINSTALLMODE:                 FilesOnlyMode
      RSSVCACCOUNT:                  <empty>
      RSSVCPASSWORD:                 *****
      RSSVCSTARTUPTYPE:              Automatic
      SAPWD:                         *****
      SECURITYMODE:                  <empty>
      SQLBACKUPDIR:                  <empty>
      SQLCOLLATION:                  SQL_Latin1_General_CP1_CI_AS
      SQLSVCACCOUNT:                 NT AUTHORITY\NETWORK SERVICE
      SQLSVCPASSWORD:                *****
      SQLSVCSTARTUPTYPE:             Automatic
      SQLSYSADMINACCOUNTS:           VISTA-PC\VISTA
      SQLTEMPDBDIR:                  <empty>
      SQLTEMPDBLOGDIR:               <empty>
      SQLUSERDBDIR:                  <empty>
      SQLUSERDBLOGDIR:               <empty>
      SQMREPORTING:                  False
      TCPENABLED:                    0
      X86:                           False
      Configuration file:            C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20141209_232121\ConfigurationFile.ini
    Detailed results:
      Feature:                       Database Engine Services
      Status:                        Failed: see logs for details
      MSI status:                    Passed
      Configuration status:          Passed
      Feature:                       SQL Server Replication
      Status:                        Failed: see logs for details
      MSI status:                    Passed
      Configuration status:          Passed
    Rules with failures:
    Global rules:
    Scenario specific rules:
    Rules report file:               C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20141209_232121\SystemConfigurationCheck_Report.htm
    I will very appriciate if someone can help me solve it. I was trying to set Full control for my account in Properties/Security of root folder and try again but error is still.
    Many thanks

    Hi Foreverduy,
    Before you run SQL Server 2008 express setup, make sure that you have installed Windows installer 4.5 and.NET Framework 3.5 SP1 manually. For more information about the process, please refer to the article:
    http://msdn.microsoft.com/en-us/library/ms143506(v=sql.100).aspx. Moreover, please turn off all the third-party softwares which could prohibit the installation process.
    According to your error message, the issue could be due to that your account has no rights to install SQL Server, or the corruption on the media.
    Firstly, please ensure that your account has admin rights. Also make sure that you right-click the setup.exe and choose “Run as administrator” to complete the installation.
    Secondly, please check if "msdbdata.mdf" file exists at d:\8268cd7b247d294de359c9\x86\setup\sql_engine_core_inst_msi\PFiles\SqlServr\MSSQL.X\MSSQL\Binn\Template. If it exists, please make sure that your account has read permission to the extracted
    folder.
    However, if the file doesn't exist in the extraction, the media could be corrupt. Please download the
    media
    again and check if the issue still occurs.
    Regards,
    Michelle Li

  • Adobe Illustrator CS4 Error: Error 1603. Error 1305.Error reading from file C:\Program Files\Adobe\Adobe Illustrator CS4\Support Files\Required\Fonts\AdobeSongStd-Light.otf.  Verify that the file exists and that you can access it.  AdobeColorCommonSetRGB

    Iam trying to load illustator in my PC i get following error while loading Application CD 2
    Adobe Illustrator CS4
    Error:
    Error 1603. Error 1305.Error reading from file C:\Program Files\Adobe\Adobe Illustrator CS4\Support Files\Required\Fonts\AdobeSongStd-Light.otf. Verify that the file exists and that you can access it.
    AdobeColorCommonSetRGB
    Error:
    Error 2.
    My serial no. [Removed by moderator]

    Download a copy an installer for CS4 from the links on this page:
    Other downloads

  • Read from file and plot data against timestamp

    Hello,
    I know that there are already many posts regarding the question I m about to ask. But, I somehow dont seem to achieve what I want using the suggestions given in the other posts.
    My problem is that, I have a file with the first column as a time stamp containing hour, minute, second and millisecond. The second column in a set of pressure values. I want to plot a graph of these pressure values against the timestamp recorded in this .txt file. Whatever I do, the timestamp values seem to skip by a couple of seconds.
    How do i do this correctly?
    Also, Is it advisable to use the read from file or the read from spreadsheet file vi? Kindly help me out.
    Thanks and regards.

    Hey, I was having a similar issue the other day.  The first problem I had was how to open the file and actually get the timestamp information.  Since I'm using LabView 8.0, I had to go into Read Spreadsheet File and create a new vi to open strings (in an array form).  That's the Read Spreadsheet File (string) vi below.  Then, I had to figure out how to convert the string of a timestamp to something meaningful to me.  The Timestamp2.vi is how I did that below.  I'm also including a little test file.  So, to run Timestamp2.vi, you will have to input the right base path, and have the Read Spreadsheet File (string).vi in the same place as Timestamp2.  Hope that helps.  I think I'm finally getting this stuff, so let me know if it doesn't work.
    Attachments:
    Test.txt ‏1 KB
    Timestamp2.vi ‏28 KB
    Read From Spreadsheet File (String).vi ‏25 KB

  • Web Service; Error attempting to read from file

    I'm trying to connect to a web service as outlined by the book "Creating Dynamic Forms with Adobe LiveCycle Designer" which is an excellent book by the way.
    I'm receiving the following error "Error attempting to read from file. http://www.webservicex.net/BibleWebservice.asmx"
    I've successfully created the Data Connection to
    http://www.webservicex.net/BibleWebservice.asmx?wsdl
    I dragged and dropped the bookTitle, chapter & Versie onto the form. I also dragged and dropped the GetBibleWordsByChapterAndVerseResult and the GetBibleWordsByChapterAndVerseBtn.
    I Preview PDF and click the button I get the above error.
    Does anyone have experience using Web Services with Adobe LiveCycle ES and have advice on how to resolve this. Any Suggestions would be greatly appreciated.
    -Todd

    Well, I have more news on the error I'm getting. - NO I didn't find the problem. Yet
    I checked and made sure that web.config had "None" selected " in authentication mode. I.E. <authentication mode="None" /> This should eliminate any authentication problems since that turns off IIS's authentication checking.
    At first I was thinking the form was generating the error trying to read the result coming back from the web service, but I put in some code that writes the result to a log file when the method fires off.
    I noticed that when I clicked on the button on the form, the error message would pop up from Acrobat, but when I check the log file, there was NO entry. This means that Acrobat failed before it could execute the method.
    Here is the web method:
    [WebMethod(CacheDuration = 30,
    Description="Returns the String 'True' or 'False' whether or
    not you entered a 'T' or 't'.")]
    public string TF(string Tf)
    string result="False";
    if(Tf.Substring(0,1).ToLower()=="t"){
    result= "True";}
    LogFile.Write("Sent: "+result);
    return result;

  • BDC read from file!

    Dear friends,
           I have one problem. When we are creating abap program by clicking on program button on recording screen it asks for the program name and there are 2 oprions..
    1) read from file and
    2)transfer from recording....second one is fine...but i am not able to use first option...how to use that and why it is used...
    Thanks And Regards,
    Bhavin Shah.

    Hi Bhavin,
          The basic difference between read from file & transfer from recording is that...
        In transfer from recording you have to give a session name or you have to choose call transaction. Here you have to give the data manually.
        The Read from file will generate a dataset where who have to give that path of your flat file. When you execute it the data from the flat file will go into the necessary fields you have choosen before. You can process the job in the back ground which will be executed and a log file will be generated so that you can check whether it is updated correctly or not.
          In general we use read from file option when we know that the data are correctly arranged for recording.
          For eg. if you want to update the database with the file you have to know the datatype and length of each database-field so that you can specify the data in a file.
          i.e Assume that you are having 2 fields in db-table of type char and length 10 & 20. Assume that you are going to give values for these fields as mala & kala.
    In the file... you should specify like this...
    mala      kala                xxx
    123456789012345678901234567890
    <---Ten--><-----Twenty------->
    In a Real Time scenario you have a very large table with 50 to 100 fields to update with a very large data like 1000 - 10,000 records and if you are not sure with the flat file data. Then you should not go for the file option.
    Hope this helps you.
    Regards,
    Maheswaran.B

  • Is there is abetter performance to read from file than my code for longfile

    Hi
    This is my code to read from file and show it in a text area ,but for long file it wait for along time to show the file ,Is there is better performance code?
    chooser=new JFileChooser();
                        chooser.showOpenDialog(sav);
                        File fe=new File(chooser.getSelectedFile().getAbsolutePath());
                        //out = new PrintWriter(new FileOutputStream(f));
                         in2 = new BufferedReader(new FileReader(fe));
                         str=in2.readLine();
                         if(str!=null)
                             nn2=str;
                         str=in2.readLine();
                        try{
                         while((str)!=null)
                         { nn2=nn2+"\n"+str;
                             str=in2.readLine();
                         }}catch(NullPointerException e){}
                         jta2.setText(nn2);
                          in2.close();
                       // in2 = new BufferedReader(new FileReader(fe));
                    } catch (IOException ex) {
              }catch(NullPointerException e){}
                  nn1=str;

    Yes you code would be slow because you are continually creating new string by concatenating one string to another.
    The easiest way is to simply use the read(...) method of the text area.

  • Error 1305 - Error reading from file C:\Users\Davy Ravenhorst\AppData\Local\Adobe\...

    Hi! I tried to download Adobe Reader 9.3 from your website (www.adobe.com), it downloaded successfully, but when I tried to install it, I got this error:
    Do you know how I can install it so it will read this file? I am not computer-savvy so I don't want to mess with the Security properties of this file nor do anything else with this (or even just anything), unless you are sure you know how to do it so it doesn't mess up my computer. Please help me install this program!! Any help on this is always greatly appreciated!!!
    Thank You.

    Elemanzer wrote:
    Sounds like something is wrong with your profile.
    Create a new admin profile and log into that and try to install adobe reader.  If that works fine, then something is wrong with your profile, if you get the same error message than something is wrong with the machine.
    You can also go to "right click" my computer and go to manage.
    Under there find "services" and see if the windows installer is disabled.
    Do you have the latest java 6.20?  Not that it's needed, but you may want to see if you can installl something else.  It may not even be Adobe, it could be that you can't install anything.
    Creating a new admin profile may not have anything to do with the installation, but I will give it a try anyway.
    Edit   I tried creating a new admin accout (it worked out succesfully), but when I tried to log into this account, the User Account service failed to log me into it, even with a new password. So this does not apply and I deleted the new account.
    As for the Windows Installer in Services, I changed the startup option from Manual to Automatic, and also started it.
    I will try running the installer to see if it installs succesfully.
    Do you think I could remove the Adobe folder from Program Files, to see if this makes a difference? This is just a suggestion. Any other suggestions please let me know.
    I was also thinking, if there are any other Adobe Reader setup files I can download? If so, please post the links in your reply.
    Edit 2   I was also wondering (or even worrying) about this:
    Does this mean I have to reinstall Windows Vista, simply because I cannot install Adobe Reader because of "missing files and/or folders" thing?!? I have been getting other installation errors from installing other programs (like for instance, I got an "Internal error ..." error because it could not find a specific Temp file when I tried to install Google Earth; or, I got some kind of an error because it could not find an "Installer" folder when I installed Dell Support Center)?!? I would HATE to do this, especially since I made (and wasted) a lot of time backing up my important files, installing Windows Vista, and THEN installing some programs. And NOW I get these errors trying to install?! Good grief!! PLEASE HELP!!

  • Reading from file one at a time

    I am trying to read from an Excel file one cell at a time, and am having some trouble. I have included my VI. Any help would be greatly appreciated.
    Attachments:
    demo.vi ‏165 KB

    Your first problem is that you are using the Read file function. This doesn't work with Excel. Native Excel files have their own special format and you have to use ActiveX to read them. If you have the report generation toolkit, you can use that or look at the examples on the Excel Board. You can also save the Excel file as comma or tab separated text and then the Read From Spreadsheet or Read File will work.
    Second, if the file is static, you would be much better off to read the file all at once to an array and then just index out the values inside the while loop. It looks like you are getting temperature values from a file. Is the Excel file being generated at the same time as your program? If it is, what is generating the file? Maybe that program can be controlled by LabVIEW and you can get the temp values directly from it. If it's a file that is constantly being updated, then the reading is going to be somewhat comlpicated if you care at all about getting the most recent value.

  • Can any1 tell me whats wrong.. trying to read from file..

    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.util.StringTokenizer;
    import java.util.Scanner;
    public class AccountClient {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            Account[] accountList = new Account[10];
                  int accountNumber = 0;
                  String accountType = "";
                  String clientName = "";
                  String socialSNumber = "0";
                  double intBalance = 0;
                  double intCheck = 0;
                  double intSave = 0;
                  int theAccountNumber = 0;
                  String theAccountType = "";
                  String theClientName = "";
                  String clientSocialSNumber = "";
                  double clientIntBalance = 0;
                  double theIntCheck = 0;
                  double theIntSave = 0;
                  int counter = 0;
                  String theSpacer;
                  String x="";
            try {
                FileReader infile = new FileReader("input.txt");
                Scanner fin = new Scanner(infile);
                fin.useDelimiter("\t");
                while (fin.hasNextLine()) {
                    accountNumber = fin.nextInt();
                    accountType = fin.next();
                    clientName = fin.next();
                    socialSNumber = fin.next();
                    intBalance = fin.nextDouble();
                    intCheck = fin.nextDouble();
                    intSave = fin.nextDouble();
                    if(accountType.equalsIgnoreCase("checking") || accountType.equalsIgnoreCase("interest checking")) {
                        accountList[counter] = new CheckingAccount(accountNumber, accountType, clientName, socialSNumber, intBalance, intCheck);
                        counter ++;
                    else
                        if (accountType.equalsIgnoreCase("saving")) {
                            accountList[counter] = new SavingAccount(accountNumber, accountType, clientName, socialSNumber, intBalance, intSave);
                            counter++;
                    PrintWriter fout = new PrintWriter("output.txt");
                    for(int i = 0; i < counter; i++) {
                        theAccountNumber = accountList.getAccountNumber();
    theAccountType = accountList[i].getAccountType();
    theClientName = accountList[i].getName();;
    clientSocialSNumber = accountList[i].getSSNumber();
    clientIntBalance = accountList[i].getInitialBalance();
    if (accountType.equalsIgnoreCase("interest checking")) {
    theIntCheck = accountList[i].getIntRate();
    else
    if (accountType.equalsIgnoreCase("saving")) {
    theIntSave = fin.nextDouble();
    x = accountList[i].toString(theAccountNumber);
    theSpacer = accountList[i].space(x.length());
    fout.print(theAccountNumber + theSpacer);
    theSpacer = accountList[i].space(theAccountType.length());
    fout.print(theAccountType + theSpacer);
    theSpacer = accountList[i].space(theClientName.length());
    fout.print(theClientName + theSpacer);
    theSpacer = accountList[i].space(clientSocialSNumber.length());
    fout.print(clientSocialSNumber + theSpacer);
    x = accountList[i].toString(clientIntBalance);;
    theSpacer = accountList[i].space(x.length());
    fout.print(clientIntBalance + theSpacer);
    if (accountType.equalsIgnoreCase("interest checking")) {
    x = accountList[i].toString(theIntCheck);;
    theSpacer = accountList[i].space(x.length());
    fout.print(theIntCheck + theSpacer);
    theSpacer = accountList[i].space(3);
    fout.print("n/a" + theSpacer);
    else
    if (accountType.equalsIgnoreCase("saving")) {
    theSpacer = accountList[i].space(3);
    fout.print("n/a" + theSpacer);
    x = accountList[i].toString(theIntSave);
    theSpacer = accountList[i].space(x.length());
    fout.print(theIntSave + theSpacer);
    fout.close();
    catch (Exception e) {
    System.out.println("error"); e.printStackTrace();
    //PrintWriter fout = new PrintWriter("output.txt");

    its supposed to read from the input file and print to the output file, but right now its throwing an exception for whatever reason. when i trace it, i get this and im not sure what its telling me
    java.util.NoSuchElementException
         at java.util.Scanner.throwFor(Scanner.java:817)
         at java.util.Scanner.next(Scanner.java:1431)
         at java.util.Scanner.nextDouble(Scanner.java:2335)
         at AccountClient.main(AccountClient.java:45)
         at __SHELL5.run(__SHELL5.java:6)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at bluej.runtime.ExecServer$3.run(ExecServer.java:858)
    java.util.NoSuchElementException
         at java.util.Scanner.throwFor(Scanner.java:817)
         at java.util.Scanner.next(Scanner.java:1431)
         at java.util.Scanner.nextDouble(Scanner.java:2335)
         at AccountClient.main(AccountClient.java:45)
         at __SHELL6.run(__SHELL6.java:6)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at bluej.runtime.ExecServer$3.run(ExecServer.java:858)
    java.util.NoSuchElementException
         at java.util.Scanner.throwFor(Scanner.java:817)
         at java.util.Scanner.next(Scanner.java:1431)
         at java.util.Scanner.nextDouble(Scanner.java:2335)
         at AccountClient.main(AccountClient.java:45)
         at __SHELL7.run(__SHELL7.java:6)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at bluej.runtime.ExecServer$3.run(ExecServer.java:858)

  • Read from File which is dynamically updated

    Hello all
    Is there any class for reading from a file which is dynamically updated?and those updates are immediatley reflects in java File object without closing previous and reopen that file again to get the latest updates?
    thanks
    sjafery

    I meant RandomAccessFile

  • Java Applet that reads from file

    I'm quite new to java, I'm fiddling around with it for a nonprofit organization.
    I have a java program that reads from a specified file and generates output but my final goal is a search box on the website that will take user input, run it through my program which searches through a prespecified file, and generate output.
    I'd appreciate any help.

    What can I do with this? I need it to be a String because I'm breaking it down to Tokens.
    Thanks,
    -Grant
    Scanner input = null; //input is going to be the Scanner object
    input = new Scanner(new BufferedReader(new FileReader("test.txt"))); /*setting up the Scanner object "input" to read the file "test.txt"*/
    String words = null;
    String MyArray[] = new String[5000];
    while (input.hasNext()) { //Puts ALL the file's data into one string
    words = words + " " + input.next(); /*Without that space the string "words" contains is all just one word making it unTokenizable*/
    }

  • Reading from files

    hello,
    I am in the process of doing my final year project. I am just doing some testing to find out certain things and I have come across this problem which I would like some advice on.
    Below is the code I am using to try this out. I am able to output the contents of a text file but not the pdf. Is this because I am using the wrong file reader or is it because PDFs like Doc files have formating, font types etc which txt files do not and therefore Java cannot read them?
    I would also like to know if Java can read one or more files and output their contents at the same time for example FileReader = new FileReader ("data.txt", "btcssbill20080601ref698520080602170743.pdf"); Therefore I won't have to create a new object each time I can just do it on one line of code?
    public static void main(String[] args) {
    // TODO code application logic here
    try
    FileReader file = new FileReader ("data.txt");
    FileReader file1 = new FileReader ("btcssbill20080601ref698520080602170743.pdf");
    BufferedReader buffer = new BufferedReader (file);
    BufferedReader buffer1 = new BufferedReader (file1);
    String line = "";
    while ((line = buffer.readLine())!= null)
    System.out.println(line);
    buffer.close();
    catch (IOException e)
    System.out.println("A read error has occured ");
    Thanks
    Tim

    prometheuzz wrote:
    Tjstrico wrote:
    I've just read that link and that says generate the PDFS. I've already got the PDF I wanna read from I don't wanna make a new one:SI'm fairly sure iText can be use to not only to create PDF's, but also to read existing ones.From the home page of iText:
    In short: the iText classes are very useful for people who need to generate read-only, platform independent documents containing text, lists, tables and images; or who want to perform specific manipulations on existing PDF documents.So, it can do "specific manipulations" on existing PDFs. That probably doesn't cover whatever the original poster's requirement was. (All we saw was code that copied data to the console. It's obvious that doesn't do anything useful for most PDF documents, so there must be more requirements beyond that.)

  • 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

  • Read from file, line number N?

    Could someone post some code or explain how can I read from a file, line number N?
    Thanks

    this is a simple way but not so professional:
    string filename="";// file name
    try{
    int N=5;// line number to read first line is line 0
    File file=new File(filename);
    BufferedReader in=new BufferedReader(new FileReader(file));
    for(int x=0;x<N;x++){
    in.readLine();
    String lineN=in.readLine();
    catch(..){
    Alex

Maybe you are looking for

  • TAN not getting coppied to Delivery in Free Goods process

    Hi I am creating a sales Order With Standard Item TAN and entering Sub Items mannually TANN, System has allowed me to do this, but when i am creating Delivery Document,System is not takeing Higher Level Item, only considering Line items wth TANN, I h

  • USB 3.0 port thinks it is USB 2.0

    I just bought a new HP ENVY 15-j101tu Notebook PC. When I plug the external USB 3.0 hard drive the system pops up message saying the device can perform faster when connected to USB 3.0. The speed of file transfer from laptop to the external hard disk

  • Why can I not upgrade my iPhone 4 iOS from version 5.1.1 to 6.x?

    I don't have enough memory, nor do I wish to upgrade to 7.x. I only want to upgrade from 5.1.1 to 6.1.2 at the latest. Why does Apple not let you do this?

  • How do I composite with a matte and fill ?

    Hi all, If I have for example, a image of the desert for the background. And then I have a logo I want to add over it. And that logo comes with a matte and fill. How do I composite that over the desert image ? I've tried working with the (add image m

  • Getting Adobe Reader to Populate 2D barcode

      Do I need Adobe Livecycle Reader Extension ES2 to allow the 2D barcode function in the Adobe Reader (it seem to function in Adobe Pro w/o any additional software, but not in the Reader). And if so what would be the price of the extension acqusition