How to delete string from an array
I just want to know that what changes i can do to delete the string if contains any extra characters like digits and punctuation marks in the middle or begining of the string but not at the end of the string, i've already tried to delete only the punctuation marks at the end of the string and keep that word. Please dont forget that i m a beginer
import java.io.*;
import java.util.*;
class Project
public static void main()throws IOException
// set up input stream
File finput = new File("C:\\f1.txt");
FileReader fr = new FileReader(finput);
BufferedReader fin = new BufferedReader (fr);
// set up output stream
File foutput = new File("C:\\f3.txt");
FileWriter fw = new FileWriter (foutput);
PrintWriter fout = new PrintWriter (fw);
String nextLine; // a line read from the file
StringTokenizer t; // the words within the line
ArrayList words = new ArrayList(); // an array of words
//String n = {0,1,2,3,4,5,6,7,8,9};
System.out.println("Reading file.\n");
// start
while (true)
nextLine =fin.readLine(); // read from input file
if (nextLine==null) break; // if no more lines, get out
t = new StringTokenizer(nextLine); // identify words
while (t.hasMoreTokens())
String str = (String)t.nextToken();
str = str.toLowerCase(); // Converting all uppercase to lowercase.
// Replacing all punctuation marks.
str=str.replace(',',' ');
str=str.replace('?',' ');
str=str.replace('!',' ');
str=str.replace('.',' ');
str=str.replace(':',' ');
str=str.replace(';',' ');
str=str.replace('"',' ');
str=str.replace('"',' ');
str=str.trim(); // Removing empty spaces after words
words.add(str); // add them to array
String z; // Declaring string z for sorting.
for (int i=0; i<words.size(); i++)
for (int j=i+1; j<words.size(); j++)
// Sorting the Array list.
if (((String)words.get(j)).compareTo((String)words.get(i))<0)
z=(String)words.get(i);
words.remove(i);
words.add(i,(String)words.get(j-1));
words.remove(j);
words.add(j,z);
// To replacing word which have got "'".
if ((String)words.get(i)).indexOf("'")!=-1)
a="";
int count[]=new int[words.size()]; //Creating int array for counting the repetition.
for (int i=0;i<=words.size()-1;i++)
for (int j=i+1;j<=words.size()-1;j++)
//Counting the repetition of the string.
//if (((String)words.get(j)).compareTo((String)words.get(i))==0)
if (((String)words.get(j)).equals((String)words.get(i))==true)
count[i]++;
words.remove(j);
j=j-1;
System.out.println("Dictionary\t|\tRepetition");
System.out.println("==========\t \t==========\n");
for (int i=0; i<words.size(); i++)
count[i]++; // initialinzing the value with 1
// Printing result on the output file.
fout.println((String)words.get(i));
// Printing result on the screen with histogram.
System.out.println((String)words.get(i)+ "\t\t|\t" +count[i]);
fout.close();
System.out.println();
System.out.println("Finished");
} //end of main.
The code that you pasted does not seem like written by a beginner. So, did you write the code?
If so, you should have no problem solving this simple thing.
If not, then copy and pasting a block of program that you don't understand will keep you as a beginner all the time, so can't help you if you are willing to stay at beginner.
--lichu
Similar Messages
-
How to delete rows from 2D array in this case...
Hello. I'm just begging adventure with labview so please for patient. I created a program whitch suppose work in following way:
2D Input array is array created by FOLDER BROWSING subVI. It works in this way,that browse folder and looking for txt files whose contanins measurment data. In my case subVI founds 4 files,and from theirs headers read information about what kind of data are in file also their's path. In this way is created 2D Input Array. subVI named PLOTS FROM PATHS ARRAY make picture with polar/XY plot. It's create only those plots and legends on one picture as many files(their paths) is setted to the program by output array. I made this subVI in that way and I would not like to change it.
My problem is that in even loop (witch check for any change by user) program suppose to relay anly those rows(files) for which checkbox are marked, e.g. marking anly 1 and 4 box, program should chose from input array row 1 and 4 only and pass them to output array,then PLOTS FROM PATHS ARRAY subVI makes a picture only with 1 and 4 plot and legend only for plot 1 and 4. The best solution would be some relay witch is avtivated by logical signal. It lost to me ideas how to solve it, I'm just in blaind corner...
I tried to use delete from array but I don't know how to do use it properly in this program,becease it can be only before or afeter for loop. Below is scan of front panel and also main problem. Please set me up somehow to solve this problem.
Regards
Solved!
Go to Solution.
Attachments:
plots selector.vi 17 KB
problem.PNG 18 KBI have attached a vi. Is this the one that you need?
Anand kumar SP
Senior Project Engineer
Soliton Technologies Pvt Ltd
Attachments:
plot selector modified.vi 14 KB -
How to delete string or line from unix file(dataset) of application server
Hi All,
After transfer workarea information or all records into dataset(unix file). When I see the file in application server automatically the last line is shown a blank line. I am not passing any blank line.
I have tried for single record than also the file generates the last line(2nd line) also a blank line.
When I m reading the dataset, it is not reading the last blank line but why it is showing the last blank line?
How to delete string or line from unix file(dataset) of application server?
Please give your comments to resolve this.
Thanks
Tirumula Rao ChinniHi Rio,
I faced similar kind of issue working with files on UNIX platform.
The line is a line feed to remove it use
DATA : lv_carr_linefd TYPE abap_cr_lf VALUE cl_abap_char_utilities=>cr_lf.
DATA : lv_carr_return TYPE char1,
lv_line_feed TYPE char1.
lv_line_feed = lv_carr_linefd(1).
lv_carr_return = lv_carr_linefd+1(1).
Note: IMP: The character in ' ' is not space but is a special
character set by pressing ALT and +255 simultaneosly
REPLACE ALL OCCURRENCES OF lv_line_feed IN l_string WITH ' '.
REPLACE ALL OCCURRENCES OF lv_carr_return IN l_string WITH ' '. -
How to delete elements from a cluster?
Hello. I would like to know how to delete elements from a cluster. I got stuck with this problem. There is its own order of each element in a cluster. I tried to initiate an array but it seems like too complicated. In the attached file, I want to obtain only the data from "flow" not "pressure". I try to use array programming but it doesn't work. Would be nice if you help me to fix the file. Thanks
Solved!
Go to Solution.
Attachments:
test 1.vi 16 KBBombbooo wrote:
What about if I want to store data into the pressure array too? Do I have to create another loop or it can be done in the same loop as the flow loop?
Try this, for example. Modify as needed.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
test1MOD2.vi 9 KB
SelectFlowOrPressure.png 7 KB -
HOW TO DELETE FILES FROM ADOBE READER IF THEY ARE UNNECESSARY
HOW TO DELETE FILES FROM ADOBE READER IF THEY ARE UNNECESSARY
Hi,
You might need to sign up at https://cloud.acrobat.com/ and choose 'Files' tab where you can find all the files.
Select all the files you want to remove and choose 'Delete' option.
Regards,
Anubha -
How to delete songs from iPod touch
How to delete songs from iPod touch
If yu have iOS 5 then swipe the sonf left or right and a delete button should appeat. tap that. For earlier IOS you need to unsync the songs.
-
how to delete video from iTunes library? del and shift+del are not working - no any reaction.
seb963 wrote:
Hi
Currently, iMatch is turned off on my computer, as I do not want to upload any more songs. If I turn it on, will it upload all songs that are currently in my library? Is there another way that deleting them one by one?
You must enable iTunes Match on the new computer. The best way to accomplish what you want to do is to create a new, empty library by launching iTunes while holding down the Option key (Shift on Windows) and choosing "new library." Do not let iTunes scan for new content, but do enable iTunes Match on the empty library. Once the scan is finished you may delete tracks from the cloud. When you are done switch back to the main iTunes library. -
How to delete applications from mac pro?
I think many people struggling at "How to delete appalications from Mac pro ,just because you made some mistakes or curious !" I know it is a bit difficut for people who are new users for the Mac .
If you really don't want them ,you can delete them easily,
As all you know after you download appalications from anywhere ,it could be from apple app store or from other websites. They all can be disspeared if you don't like them .
First , If you installed from apple app store it will be really easily just click at the app on the launchpad, after few seconds all the apps will be all shaking like leaves ,yes they are scared .(No No don't delete me I am helpful !) Ok yes that is a little joke ! so what you can see now there is a small "x" at the top right corner .Can you see them ? just click the "x" And they will gone .
Second step. This is only for you downoaded from other websites , In that case , you just skip first step come to here in order to save you some golden time .
You can delete them from the launchpad , I have tried many times . i tried to drug them in the the trash . But after them all jump back to where they are , So you need to open the Finder ---> click the download -----> find the file which is belong to the app (make sure ) ------->click it -----> drug it into the trash. then you can hear a little sound like you through it into the bin. it is really humanny isn't it ? then go back to the finder again .---->click the application -------> find the icon on there which is you just drag into the trash. do it again . take this one into the trash as well then you will find the icon on the launchpad is disppeared . at the end don't forget to empty your trash After that all job done , it is been deleted ,
Well done !
Hope this could help all of your!
Thanks for reading !Your profile shows Macbook Pro yet your topic confirms you are talking about a Mac Pro - or
-
How to delete songs from itunes backup file
how to delete songs from itunes backup file
There is nothing to delete, as no iTunes content is included in any iPhone backup.
-
I need to delete photos from my iPad that were synced with an old version of iTunes on a computer that is no longer functioning. Please help.
Alos, I need to move many photos from my iPad to storage place. Any recommendations on backup drives for an iPad 2?The links below have instructions for deleting photos.
iOS and iPod: Syncing photos using iTunes
http://support.apple.com/kb/HT4236
iPad Tip: How to Delete Photos from Your iPad in the Photos App
http://ipadacademy.com/2011/08/ipad-tip-how-to-delete-photos-from-your-ipad-in-t he-photos-app
Another Way to Quickly Delete Photos from Your iPad (Mac Only)
http://ipadacademy.com/2011/09/another-way-to-quickly-delete-photos-from-your-ip ad-mac-only
How to Delete Photos from iPad
http://www.wondershare.com/apple-idevice/how-to-delete-photos-from-ipad.html
iPhoto for iOS (iPad): Delete photos from iPhoto
http://support.apple.com/kb/ph3137
How to: Batch Delete Photos on the iPad
http://www.lifeisaprayer.com/blog/2010/how-batch-delete-photos-ipad
(With iOS 5.1, use 2 fingers)
How to Delete Photos from iCloud’s Photo Stream
http://www.cultofmac.com/124235/how-to-delete-photos-from-iclouds-photo-stream/
~~~~~~~~~~~~
There are some wireless external hard drives that can be used with the iPad.
Best iPad External Hard Drive Storage Options
http://www.unlocktips.com/2012/11/best-ipad-mini-external-hard-drive-memory-stor age-options/
Another option:
Expand your iPad's storage capacity with HyperDrive
http://www.macworld.com/article/1153935/hyperdrive.html
On the road with a camera, an iPad, and a Hyperdrive
http://www.macworld.com/article/1160231/ipadhyperdrive.html
Cheers, Tom -
Reg:-How to delete PO from Table
Hi,
I need to know how to delete PO from the table.I know for item deletion.
Edited by: Venkadesh on May 22, 2009 2:53 PMHi
PO's cannot be deleted from the table, we can only archive them from the data base being used.
Deletion flag in the PO will not remove data from table.
Thanks & Regards
Kishore -
I trasferred pictures over from my computer to my iPhone 5 and now i cannot delete these pictures from my phone, and i cannot work out how to delete them from my phone by the computer as the pictures do not show up in my files on the computer, how can i remove them i have over 400 pictures that need removing?
If you have a Mac with iPhoto, plug the iPhone in and open iPhoto. Choose to import the photos. Once they have been imported, there should be an option to "Remove Imported Photos from Device". Choose this.
-
Can anyone help me out ?
I would like to get info on how to DELETE
iCLOUD from my desk top MAC.
Would it already have synced to the iPAD?
Apple does not give any info on the iCLOUD,
in a proper way to DELETE..for that matter,
I can't even find "SETTINGS" on my Mac,
let alone settings for iCLOUD.Any info
would be better than what Apple gives up.
Apple is useless when trying to get any information!You have to search with some patience and you will find all the informations on the Apple support pages and here in this forum.
You find i Cloud in SAFARI at www.icloud.com and set as you like.
Usually iCloud sincs all the devices which have the same AppleID.
If you wish to use devices for different persons you need to give them different AplleID and on the MAC create different User Accounts. Each will be fully separate.
Or you can go to settings (settings are to be found under the apple icon on top left of the screen) and from there open Sistem Preferences and iCloud. -
How to delete data from single field in a database table?
Hi guys,
Plz suggest me How to delete data from single field in a database table?
thnks,
pavanhi
in addition to abv details..chk this:
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3aef358411d1829f0000e829fbfe/content.htm
http://dev.mysql.com/doc/maxdb/en/34/ee7fbd293911d3a97d00a0c9449261/content.htm
regards,
madhu -
HT4236 how to delete photos from photo libarby
how to delete photos from photo album
Delete them on your computer, then sync your iPad to your computer.
Maybe you are looking for
-
Office Home and Student 2013 on Windows 8.1
I bought the above software for a new laptop from a company called Information Technology Clear Limited. I downloaded it using the key they sent me. To start with it worked on and off, opening some documents, not others, then telling me it couldn't s
-
Hello All, I am trying t load metadata via Interface tables in my EPMA application. I loaded all the metadata correctly & my application got delpoyed with any error. Hoewever I am having some issue with loading member fromula in my version dimension.
-
Adobe LightRoom Won't work well in Leopard
Don't install Leopard if you use Lightroom. It slows down to the point it is unusable at least for me. After I installed Leopard and found LR not working, I found a note on Adobe site which says it isn't compatible yet but will be in the future. No d
-
BAPI_GLX_GETDOCITEMS and no Cost Center Data
Hi, i'm using the BAPI "BAPI_GLX_GETDOCITEMS" to extract all documents from General Ledger. This BAPI returs the structure "ITEMSLIST" which contains a field for the Cost Center. I took a look at several Documents via FB03 and there are many document
-
Recent Email - Important changes to your BT Infini...
I got this email the other day, see below Hello, You can now get faster broadband speeds in your neighbourhood because we've improved our network. And they won't cost you a penny extra. Your upload speed could go from up to 2Mb to up to 9Mb (your dow