Can't read a delimiter

Guys,
I am reading in a text file, and I am trying to write an interface to read in the different words in there...so I am using a tokenizer for the delimiter...in the text file the delimiter shows as |, but when the file is read in java the string looks like this Fields:�REFNO�SEQNO�VERSION�OBSTRLM�FLOW�RPOISS�RTURB�PGRAD�...so i am trying to have two delimiters...one for the : and another for that other 3 symbol loook a like...but I am getting lost now cuz the file can not read the | delimiter...can anyone help please...
here is my code:import java.io.*;
import java.util.*;
import java.text.*;
import java.util.Date;
import java.lang.String;
public class file {
public static void main(String[] args) throws IOException {
// Display today's date using a default fomat for the current locale
DateFormat defaultDate = DateFormat.getDateInstance();
System.out.println(defaultDate.format(new Date()));
// Display Current time using a short time format for the current locale
DateFormat shortTime = DateFormat.getTimeInstance(DateFormat.SHORT);
System.out.println(shortTime.format(new Date()));
// Display date and time using a long format for both
DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
System.out.println(longTimestamp.format(new Date()));
// Declare Variables
StringBuffer desc;
// Keep looking through the file while it is still not end of file
try {           
// Opens the file and reads it
File theFile = new File("23133202.2");
BufferedReader in = new BufferedReader(new FileReader(theFile));
// Get Length of File, and see how big it is
long filelength = theFile.length();
Date lastModified = new java.util.Date(theFile.lastModified());
String str = new String("");
int i=0;
// Read the file line by line using a Token
while((str = in.readLine()) != null){
StringTokenizer st = new StringTokenizer(str,"|");
int count = st.countTokens();
toIndex = s.IndexOf("|", fromIndex);
if (toIndex!= -1) {
String firststring = s.substring(fromIndex, toIndex);
fromIndex = toIndex++;
// tokener contains all the field variables
String tokener = new String("");
//Vector vec = new Vector();
System.out.println();
while(st.hasMoreTokens()){
//vec.addElement(st.nextToken());
tokener = st.nextToken();
System.out.println(tokener);
//System.out.println(str);
int x = tokener.indexOf("Fields");
int y = tokener.indexOf("Group");
System.out.println(x);
System.out.println(y);
} // end while
//String[] strArray = new String[vec.size()];
//vec.copyInto(strArray);
//for (i=0; i<strArray.length; i++){
// System.out.println(strArray);
} // end the main while
// end try
catch (EOFException e) {
// end catch...in.close();

Ok I guess I put in the string wrong...so here is the
string that I am trying to divide
Fields:|REFNO|SEQNO|VERSION|OBSTRLM|FLOW|RPOISS|RTURB|P
RAD|, but when i read that in java, it reads the |
delimiter as a 3 symbol...and I guess the ASCII Code
for that is 179...but I dont know how to use that in
my program. How could I read the ASCII code Character
179 which is |, in my program.I could not get your code to compile. So I declared fromIndex and toIndex as int and assumed that s = str. test.txt has one line in it - |REFNO|SEQNO|VERSION|OBSTRLM|FLOW|RPOISS|RTURB|PRAD|, . This program compiles and prints out the tokens . Let me know if any of my assumptions are wrong .
public static void main(String[] args)
          // Display today's date using a default fomat for the current locale
          DateFormat defaultDate = DateFormat.getDateInstance();
          System.out.println(defaultDate.format(new Date()));
          // Display Current time using a short time format for the current locale
          DateFormat shortTime = DateFormat.getTimeInstance(DateFormat.SHORT);
          System.out.println(shortTime.format(new Date()));
          // Display date and time using a long format for both
          DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
          System.out.println(longTimestamp.format(new Date()));
          // Declare Variables
          StringBuffer desc;
          BufferedReader in = null;
          // Keep looking through the file while it is still not end of file
          try
               // Opens the file and reads it
               File theFile = new File("test.txt");
               in = new BufferedReader(new FileReader(theFile));
               // Get Length of File, and see how big it is
               long filelength = theFile.length();
               Date lastModified = new java.util.Date(theFile.lastModified());
               String str = new String("");
               int i=0;
               int fromIndex = 0;
               // Read the file line by line using a Token
               while((str = in.readLine()) != null){
               StringTokenizer st = new StringTokenizer(str,"|");
               int count = st.countTokens();
               int toIndex = str.indexOf("|", fromIndex);
               if (toIndex!= -1)
                    String firststring = str.substring(fromIndex, toIndex);
                    fromIndex = toIndex++;
               // tokener contains all the field variables
               String tokener = new String("");
               //Vector vec = new Vector();
               //System.out.println();
               while(st.hasMoreTokens())
                    //vec.addElement(st.nextToken());
                    tokener = st.nextToken();
                    System.out.println(tokener);
                    //System.out.println(str);
                    int x = tokener.indexOf("Fields");
                    int y = tokener.indexOf("Group");
                    System.out.println(x);
                    System.out.println(y);
               } // end the main while
               in.close();
          // end try
          catch (Exception e)
               try {
               in.close();
               catch (Exception ignore) {   }
               e.printStackTrace();
          // end catch...in.close();
     }

Similar Messages

  • I have a acrobat reader, can I import text delimited data format to a PDF Form so that it can auto fill into forms that was created? If not, what about FDF and XML data

    I have a acrobat reader, can I import text delimited data format to a PDF Form so that it can auto fill into forms that was created? If not, what about FDF and XML data

    Yes, you can do all of that via Tools - Forms - More Form Options - Import Data, if you have Acrobat.
    If you only have the free Reader then you can still do it, but it requires a script.

  • Reading comma delimited files

    Hi,
    What are the FMs that I can use to read comma delimited files. Also, will it be able to run in the background?
    Thanks,
    RT

    Hi Rob
       As far as i know, we can not upload data from
    persentation server in background. For that the file
    needs to be placed in application server and use Open dataset command.
    Below is just an example to help you have a feel of the
    same.
    eg:
    type: begin of t_data,
            vbeln like vbak-vblen,
            posnr like vbap-posnr,
            matnr like vbap-matnr,
            menge like vbap-menge,
          end of t_data.
    data: it_data type standard table of t_data.
    data: wa_data type t_data.
    data: l_content(100) type c.
      open dataset p_file for output in text mode.
      if sy-subrc ne 0.
    *** error reading file.
      else.
        do.
          read dataset p_file into l_content.
          if sy-subrc ne 0.
             close dataset p_file.
             exit.
          else.
             split l_content at ',' into wa_data-vbeln
               wa_data-posnr wa_data-matnr wa_data-menge.
             append wa_data to it_data.        
          endif
        enddo.
      endif.
    Hope this helps you.
    Kind Regards
    Eswar

  • Can't get a delimiter between Reapting Table Fields using the Double Eval formula.

    I have a problem in setting up the "Double Eval" formula, for a repeating table field.
    Background:
    I have a multiple-selection list box in an InforPath (2010) form. I want to concat all selected values in the list box and display them in a textbox with ";" as delimiter. I've gotten so far that with rules running when the list box is updated, the
    textbox content is updated listing the IDs of the selected items (I'm not sure yet if I want to display the IDs or make a lookup for the true text values, but that's another issue for later...).
    Problem:
    My problem is that I can't get the delimiter between the values. They are all listed in sequence with the ";" delimiter only at the end.
    I use the following formula ("Required" is the repeating field)
    eval(eval(Required; 'concat(., ";")'); "..")
    and get the following result:
    What I want to get into the comments text box is the string "684;239;91;".
    Any ideas what's wrong with my formula?
    (Using InforPath 2010 on a list published to SharePoint 2010.)

    Additional info that maybe is important to know:
    The multiple-selection list box is getting its values from a secondary data connection using a web service call:
    http://MySite/_vti_bin/ListData.svc/MyList?$filter=((CT%20eq%20'Product')%20and%20(CompGroup%20ne%20'OS'))&$orderby=Title
    The selections in my list box is yet stored in the field "Required" in a different SharePoint list, we can call it "BaseList", at the same site ("MySite").
    So to summerize:
    List 1: MySite/MyList
    Fields: CT, CompGroup, Title
    List 2: MySite/BaseList
    Fields: Required
    The different lists have more fields of course, but no need to list them all.

  • How can I read a file directly please?

    Hello everyone,
    How can I read a file directly from a script please? I tried the insert into ... values but it does not work. I really have to read the file instead of entering the data via the interface. Does Oracle have a copy command? Each file line is split with tabs for each field in the line.
    Finally how can I subdivide the strings in each field?
    Thank you very much indeed and sorry for the basic questions.
    André Luiz

    SQL> create or replace directory data_dir as '/tmp';or
    SQL> create or replace directory data_dir as 'c:\temp';Where /tmp or c:\temp are directories or folders on the server.
    A full example of importing a tab delimited file is here.
    Re: Using DML order to import a .xls file

  • How can I read an excel file .xls from an forms 6i

    Hi
    I have forms6i and webutil don t work with this version, can I read an excel file from forms6i.
    Thank u

    Hi hosoriol,
    You can refer an excel as an external table first using the steps below and then you can start reading from it.
    If you want to update the excel file then create an view and create instead of triggers for it.
    Steps
    h3. 1.[Create an external table for the excel file |http://www.adp-gmbh.ch/ora/misc/ext_table.html|Click here to view detailed description]
    h4. 1. Create a directory in Oracle where you have kept the xls file
    create or replace directory ext_dir as '/home/rene/ext_dir';h4. 2. grant read, write on directory ext_dir to scott;
    h4. 3. creating the external table
    create table ext_table_csv (
                                                i   Number,
                                                n   Varchar2(20),
                                                m   Varchar2(20)
                     organization external (
                                                     type   oracle_loader
                                                     default directory ext_dir
                                                    access parameters (
                                                                                 records delimited  by newline
                                                                                 fields  terminated by ','
                                                                                  missing field values are null
                                                   location ('file.csv')
                     reject limit unlimited;
    Note_
    If you want to update the excel file then create a view and then create the instead of triggers to do the update, delete or insert.[Creating views on external tables | http://www.dba-oracle.com/oracle_news/2005_9_1_updating_external_tables.htm]
    h3. 2. Use the data block wizard and connect to the corresponding schema and create a database block.
    Kindly click Correct or Helpful if it helps Thanks :-)

  • How can I read email from my aol account from my iphone and keep it as uread on my computer at home.  It automatically goes to read mail on my computer.  On my computer if I want to keep an email to answer later I can mark it "Keep as New".

    How can I read my email from my aol account from my iphone and keep it as "unread" on my computer at home?  At home I can read an email and if I want to get back to it at a later date I can mark it as "keep as new".  I tend to forget it if it goes to "read" mail.   Right now, when I read an email from my phone it goes automatically to "read" mail.

    On the iPad, using the mail app, there is no way to do what you are asking without tapping the flag icon and marking the item as unread. Have you tried the OWA app for the iPad? It may have that functionality, but I haven't tested it as you need an Office 365 subscription with Exchange support to use the app.

  • Is there a way to darken the dates (numbers) on ical. After installing Lion I can barely read the dates of the month in ICal

    Is there a way to darken the dates (numbers) on the ICal calender. I can barely read mine after installing Lion.

    I should note that the time stays on the left of the event name when I re-enter the text (which I had to do all the time before I found the "show event times" button) so I feel like there's a way.

  • Windows Easy Transfer (WET) Issues with External Hard Drive - "Can't read from the source file or disk"

    I work for Office Depot, in the tech department. Basically, one of our associates was supposed to do a data backup, and re-install Windows 7, then transfer the files back. He used Windows Easy Transfer and compacted everything into a 163 GB file. 
    Now comes the hard part. When we try to put it back on his computer ((drag-and-drop to the desktop) which has been wiped back to factory settings using the recovery partition), it stops at 79.5 GB remaining (you know how it doesn't give you a % of completion,
    it just shows how many GB are remaining) and then says "Can't read from the source file or disk" and gives you an option to try again, or cancel. It gets hung up on the same point each time.
    Normally, this wouldn't be a huge issue, but the contents on the drive are his wife's architect blueprints and interior design stuff, along with wedding photos, etc, which are the only copies they have. On top of those, they have court documents and other
    important files that we are unable to access now.
    I wasn't involved with this transfer, so I'm trying to clean up the mess as best I can. I remembered that the customer's wife was Russian, and had some files typed with a Russian keyboard, so on and so forth. I wonder if that's the issue? If not, I really
    have no idea how to manually extract things from a ".mig" file, or how to diagnose what area is potentially corrupted.
    In light of this situation, we tried using "Recuva" to recover the files post-wipe, but everything was corrupted or unable to be opened, and it also extracted and recovered all of the "useless" photos, such as the skype logos, up and
    down arrows for browsers, etc (it was 160,000+ photos).
    Trying to avoid a potential lawsuit, unhappy customer, and costing the company lots of money to see if professionals can get into this external hard drive.
    Other relevant information:
    We used a Toshiba 500 GB (465 GB) external hard drive.
    Customer's computer is an HP Pavilion P6000 Series (Model No. p6520y) running Windows 7 Home Premium 64-bit Service Pack 1.
    Any other information that is needed can be provided, thanks in advance, and hopefully we can find a solution to this issue quickly!
    -John

    I think there's a lack of understanding somewhere.
    "If you even can't start the process, please unplug it from your new PC. Then head back to your new computer and plug
    the external drive back in to your new computer. "
    Unplug from new, head back to new, plug it back in? That doesn't make much sense! Haha.
    I knew what you meant though, somewhat. When I search through the drives after clicking yes (Has windows easy transfer
    already saved your files blah blah blah) I click on the transfer file and it says "Windows Easy Transfer could not open the file".
    Rather than drag-and-drop the file to the desktop, I now tried to double-click on the file itself while it was plugged
    into the computer. It opened, and it started transferring until it was about 70% completed, and then an error popped up saying "WET can't open the easy transfer file, make sure your USB device is plugged in or check your internet connection". 
    I checked, and the USB hard drive's light wasn't on. Now, I unplug it and plug it back in, and the light comes back on,
    so I click Retry, and it resets the bar back to nothing and says "Transfer time: 1 minute".
    Rather than continue trying, I clicked "Cancel" instead of Retry, and it says "Your transfer did not complete successfully."
    It says to click "view report" for more information, but there's no "view report button".
    At the moment, I am scanning the External Drive for bad sectors using the check disk tool in properties. It's frozen
    at "0 USN bytes processed".

  • Can't read or write some files, internet is failing, youtube won't load, software I tried to install was in Slovenian, not dutch or english like in my systempreferences settings, pictures and files won't preview with spacebar, etc. Malware?

    Specs:
    iMac 10.8.5
    3,4 GHz Intel Core i7
    32 GB 1600 MHz DDR3
    Can't read or write some files, internet is failing, youtube won't load, security software I tried to install was in Slovenian, not dutch or english like in my systempreferences settings, pictures and files won't preview with spacebar and are randomly corrupted, when I entered something in the Youtube searchbar (when it was still working) it send me to a site with sexadds.
    I tried restart my iMac and when I was logged back in, my dock preferences were reset.
    Also tried to download some security software to check my Mac for malware, but when I did, I tried several, I got a notification that said something like 'dumpfiles (don't know if this is the right translation...) damaged'.
    I'm taking screenshots from all the weird notifications I get and even three quarters off the screenshots I took in the last three hours are already unreadable.
    It started this morning when I tried opening a Premiere Pro file on which I worked the night before.
    When I tried opening it, it said the file was damaged and could not be openend.
    I tried opening it with AE or importing the file in a new project but nothing helped.
    When I tried looking for autosaves, this is the really weird part, there were none.
    Even though there are autosaves from my other projects, this one was completely gone.
    It looked like the day before never happened on my computer.
    Also when I openend Premiere all the recent projects had been wiped.
    So at first I thought it was a Premiere Pro failure.
    But than, later on the day, I tried loading some RAW files from my compact flash card.
    This is where I would get an error (error -36) which said some data cannot be read or written.
    I tried importing the files with a view different technics, from dragging to importing via Lightroom and I succeeded with Image Browser.
    But when I tried moving the files to an other folder the same error occurred.
    While dealing with this issue I wanted to put on some soothing music on youtube.
    This is when the next weird thing occurred: youtube wasn't completely loading in Chrome. I refreshed a view times, checked the internet connection and still no difference.
    When I tried in Safari it did work but when I clicked enter on the searchbar in Youtube, a page with sexadds appeared (I didn't install AdBlock in Safari...).
    I read about this 'phishing' where you are redirected to a site were a possible malware installment can take place...
    I don't know if it's connected to any of the problems I've been having but I just never experienced this on a mac, I have been a Mac user for 10 years now.
    On top of it all, internet started working worse and worse and now it's not even working at all. I had to fill in the password over and over, normally it remembers.
    Just like my system preferences, all the preferences I had with Chrome where also reset.
    Also somewhere in between I got this notification: Mac OS X must restore library to run programs. Type your password to allow.
    To me this is all very weird and suspicious. I have clearly no idea what's going on. Could this be another sort of trojan horse or malware?
    Some background info which could be helpful for solving this mystery:
    two months ago the one year old Fusion Drive in my iMac just broke out of nowhere.
    I got it replaced by a qualified apple repair store.
    When I got my computer back, all the files where gone.
    I got on the internet without AdBlock installed yet.
    A game or whatever it was, can't clearly remember, got installed by accident.
    I deleted it immediately.
    Only two weeks later, I couldn't log in to my account. It didn't recognize my password and username. 
    So I brought my mac back to the store.
    Here the repair guy said it was a minor thing and he just needed to reconnect my account. He also mentioned he found a downloaded game name Sparta and it probably had something to do with the error.
    I asked him; could it be a virus? He replied no way.
    I don't know why I couldn't be a virus, just because it's a mac doesn't mean it cannot be done.
    So today I tried installing anti virus software (such as avast- was in a weird language looked like slovenian, clamxav - was in slovenian) but I couldn't install them.
    PLEASE help me! I don't know what to do anymore, I work fulltime and I need my computer, I have no time to bring it in for repair, are there other perhaps easier ways?
    Could this be the work of a virus or a malware? Or is it a disk permissions issue?

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

  • I have an external hard drive, from Iomega. However, I cannot copy or save any file to it. On my PC it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?

    I have an external hard drive, from Iomega. that I can open and see my files. However, I cannot copy or save any file to it. On my PC I have it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?
    Also, Im a photographer, so I like to name a lot of files at the same time (used to do in on PC and it was very usefull.) cannot find out how to do it on my Mac. Really appretiate if some one can give me a solution! Thanx

    Your drive is formatted with the NTFS file system.  OS X can read but not write to the NTFS file system.  There are third party drivers available that claim to add the ability to OS X to write to an NTFS partition.  I have not tried them and don't know if they work.
    The only file system that OS X and Windows can both write to natively is the FAT32 file system.

  • Can Yosemite read a snow leopard Time Machine backup

    Can Yosemite read a snow leopard Time Machine backup. Once I installed Lion over SL and it was a disaster since I could not get any docs or photos back, so had to put SL back on my old iMac.
    Will 10.10 give the same problem or is there a way to migrate the old 10.6.8 data to 10.10?
    Thanks

    Yes, you can do that. The only limitation is that you can't encrypt the backup volume.

  • Can not read trace of controlfile...

    hello,
    we have Oracle 10G production database on RAC on windows 2003 Enterpr 64 bit.
    i wanted to take the trace of controlfile and read the contents of same..
    i took the backup of controlfile with the
    sql> alter database backup control file to 'd:\control.trc'; then with the help of tkprof i transferred that trace file into txt
    tkprof d:\control.trc d:\control.txt but whn i try read that its giving me nothing..the size of the tracefile hows something 15480kb and that of the text file created by tkprof is only 2k..how is that?
    i also tried to open the tracefile with wordpade..but it shows me junk value...
    how can i read trace of that file
    need your help...
    thank you..

    because thats the controlfile itself, and not its "trace"
    SQL> alter database backup controlfile to trace as 'd:\control.trc';

  • I can't read my eBooks I purchase from iTunes on my desktop or laptop.  Do I need to go Amazon?  Kindle?

    Is there a future upgrade or availability to read eBooks purchased from iTunes on my desktop or laptop Mac?
    If not, I am just going to get the free Kindle application and buy all of my ebooks from Amazon as I can read them on any Mac.
    I purchased a book from Apple yesterday so that I could read it as a break during my work day at my office and it would not open.  I checked and sure enough, you can't read books on your desktop Mac using Apple software.  I tried the Adobe Digital software and a couple of others but the protection on the ebook prevented anything but my iPad or, if I had one, iPhone from reading it.
    Considering that I spent many thousands on getting the best Macs for work and only hundreds on the pad, it is just a little irritating that I can't read a book on the pro machinery but can on the consumer toy.

    We don't know what Apple plans on doing to change this (and it may not be just Apple but more likely the publishers, since Apple would, of course, do whatever it could to maximize sales/profits).  Right now you can only read Apple books on mobile devices. Sure, buy them from Amazon if you want to read them on the computer. We don't work for Apple so we're pretty impartial on this kind of advice.
    You might also see what your library can offer.  My wife can browse the county library from her iPhone, borrow e-versions, and read books on it too.  Free!

  • Portal application can't read request info

    hi all,
    i use  portal application for change portal user's infos.but when i sent request info,
    request.getServletRequest().getInputStream() method is cutting my sending line after 90. character.
    in R3 side i use HTTP_POST function and fill request info (table paramater).
    i tried to send 2 line(less than 90 character) in request info, but i can't read second line in java code.
    Is IPortalComponentRequest accept only 90 character ?
    how can i solve this problem , any idea ?
    my code is below, variable "str" is filling only first 90 character;
         protected void doOnNodeReady(
                   IPortalComponentRequest request,
                   IEvent event) {
         String str = "";
         try {
              InputStream is = request.getServletRequest().getInputStream();
              InputStreamReader isr = new InputStreamReader(is);
              int c;
              while ((c = isr.read()) > -1) {
              str = str + (char) c;
                } catch (java.io.IOException ex) {
                 str = "Error accessing input stream";
    thanks

    New discovery...If I shut down all instances of IE on my machine, then reopen my test form, it works. Once. The second time I try it I get the same peculiar behavior again, until I again shut down all instances of IE.

Maybe you are looking for

  • Business rules for Adhoc

    Hi All, I have created a web form and I want to do the Adhoc analysis on it , when right click the form and go to Adhoc session , I see the "Business rules for Adhoc" is coming as "calculate Currencies" and "calculate Form". But I want to add my Busi

  • Custom Infotype _HCM

    Dear Colleagues, Require to create Custom Infotypes for Joining , Separation & Back Graound check. I understnad we can do it using T.Code PPCI. However i am not able to do so as system is giving message to check for the Info type number. Please guide

  • Looping movie clips

    I want to loop 5 movie clips so that one clip moves onto the stage, stays there for a certain time, then moves off the stage, then the next one. Any help is greatly appreciated! Here's what I've got so far: var m1_mc = new m1(); var m2_mc = new m2();

  • ORA-20001: Invalid parsing schema for current workspace ID

    I recently upgraded Apex version from 4.0 to 4.2 successfully. Everything looks good except in one of the applications, I am running into ORA-20001: Invalid parsing schema for current workspace ID ( see below for detailed debug info). It seems this p

  • I need help duplicating a button

    I have a button that I often have to put on forms, so I have a pdf with nothing but that button in it. Whenever I need to use the button I open the pdf, go into my forms tools, edit the form, copy the button, and then paste it into the pdf that needs