Search Results

Search found 37183 results on 1488 pages for 'string conversion'.

Page 114/1488 | < Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >

  • Dividing a string into substring in JAVA

    - by Santhosha
    Hi, As per my project I need to devide a string into two parts. below is the example: String searchFilter = "(first=sam*)(last=joy*)"; Where searchFilter is a string. I want to split above string to two parts first=sam* and last=joy* so that i can again split this variables into first,sam*,last and joy* as per my requirement. I dont have much hands on experience in java. Can anyone help me to achieve this one. It will be very helpfull. Thanks in advance

    Read the article

  • struts2 StringLengthFieldValidator annotation not working for empty string

    - by dcp
    Let's say I have this annotation for a struts2 validation: @StringLengthFieldValidator(key = "key14", fieldName = "poNumber", minLength = "1", maxLength = "255", message = "poNumber must be between 1 and 255 characters.") public void setPoNumber(String poNumber) { this.poNumber = poNumber; } The behavior I'm seeing is that if I pass a string that is empty to this setter, (ex. setPoNumber("")) the validator doesn't catch the error. Strings that are over 255 are caught fine. Equally strange is if I change minLength to 2 and pass a string of length 1, it will catch the error as well. But empty string does not seem to be caught when minLength = "1". For this reason, I cannot use this validator. I just wondered if I'm doing something wrong. I'm using struts 2.1.8.1. Thanks for any advice.

    Read the article

  • Is regex too slow? Real life examples where simple non-regex alternative is better

    - by polygenelubricants
    I've seen people here made comments like "regex is too slow!", or "why would you do something so simple using regex!" (and then present a 10+ lines alternative instead), etc. I haven't really used regex in industrial setting, so I'm curious if there are applications where regex is demonstratably just too slow, AND where a simple non-regex alternative exists that performs significantly (maybe even asymptotically!) better. Obviously many highly-specialized string manipulations with sophisticated string algorithms will outperform regex easily, but I'm talking about cases where a simple solution exists and significantly outperforms regex. What counts as simple is subjective, of course, but I think a reasonable standard is that if it uses only String, StringBuilder, etc, then it's probably simple.

    Read the article

  • Convert string value into decimal with proper decimal points

    - by sharad
    i have value stored in string format & i want to convert into decimal. ex: i have 11.10 stored in string format when i try to convert into decimal it give me 11.1 instead of 11.10 . I tried it by following way string getnumber="11.10"; decimal decinum=Convert.ToDecimal(getnumber); i tried this also decinum.ToString ("#.##"); but it returns string and i want this in decimal. what could be the solution for this?

    Read the article

  • Reason for Null pointer Exception

    - by Rahul Varma
    Hi, I cant figure out why my program is showing null pointer exception. Plz help me...Here's the program... public class MusicListActivity extends Activity { List<HashMap<String, String>> songNodeDet = new ArrayList<HashMap<String,String>>(); HashMap<?,?>[] songNodeWeb; XMLRPCClient client; String logInSess; ArrayList<String> paths=new ArrayList<String>(); public ListAdapter adapter ; Object[] websongListObject; List<SongsList> SngList=new ArrayList<SongsList>(); Runnable r; ProgressDialog p; ListView lv; String s; @Override public void onCreate(Bundle si){ super.onCreate(si); setContentView(R.layout.openadiuofile); lv=(ListView)findViewById(R.id.list1); r=new Runnable(){ public void run(){ try{ getSongs(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (XMLRPCException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; Thread t=new Thread(r,"background"); t.start(); Log.e("***","process over"); } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); } private Runnable returnRes = new Runnable() { @Override public void run() { Log.d("handler","handler"); removeDialog(0); p.dismiss(); list(); } }; public void list() { Log.d("#####","#####"); LayoutInflater inflater=getLayoutInflater(); String[] from={}; int[] n={}; adapter=new SongsAdapter(getApplicationContext(),songNodeDet,R.layout.row,from,n,inflater); lv.setAdapter(adapter);} private Handler handler = new Handler() { public void handleMessage(Message msg){ Log.d("*****","handler"); removeDialog(0); p.dismiss(); } }; public void webObjectList(Object[] imgListObj,String logInSess) throws XMLRPCException{ songNodeWeb = new HashMap<?,?>[imgListObj.length]; if(imgListObj!=null){ Log.e("completed","completed"); for(int i=0;i<imgListObj.length;i++){ //imgListObj.length songNodeWeb[i]=(HashMap<?,?>)imgListObj[i]; String nodeid=(String) songNodeWeb[i].get("nid"); break; Log.e("img",i+"completed"); HashMap<String,String> nData=new HashMap<String,String>(); nData.put("nid",nodeid); Object nodeget=client.call("node.get",logInSess,nodeid); HashMap<?,?> imgNode=(HashMap<?,?>)nodeget; String titleName=(String) imgNode.get("titles"); String movieName=(String) imgNode.get("album"); String singerName=(String) imgNode.get("artist"); nData.put("titles", titleName); nData.put("album", movieName); nData.put("artist", singerName); Object[] imgObject=(Object[])imgNode.get("field_image"); HashMap<?,?>[] imgDetails=new HashMap<?,?>[imgObject.length]; imgDetails[0]=(HashMap<?, ?>)imgObject[0]; String path=(String) imgDetails[0].get("filepath"); if(path.contains(" ")){ path=path.replace(" ", "%20"); } String imgPath="http://www.gorinka.com/"+path; paths.add(imgPath); nData.put("path", imgPath); Log.e("my path",path); String mime=(String)imgDetails[0].get("filemime"); nData.put("mime", mime); SongsList songs=new SongsList(titleName,movieName,singerName,imgPath,imgPath); SngList.add(i,songs); songNodeDet.add(i,nData); } Log.e("paths values",paths.toString()); // return imgNodeDet; handler.sendEmptyMessage(0); } } public void getSongs() throws MalformedURLException, XMLRPCException { String ur="http://www.gorinka.com/?q=services/xmlrpc"; URL u=new URL(ur); client = new XMLRPCClient(u); //Connecting to the website HashMap<?, ?> siteConn =(HashMap<?, ?>) client.call("system.connect"); // Getting initial sessio id String initSess=(String)siteConn.get("sessid"); //Login to the site using session id HashMap<?, ?> logInConn =(HashMap<?, ?>) client.call("user.login",initSess,"prakash","stellentsoft2009"); //Getting Login sessid logInSess=(String)logInConn.get("sessid"); websongListObject =(Object[]) client.call("nodetype.get",logInSess,""); webObjectList(websongListObject,logInSess); Log.d("webObjectList","webObjectList"); runOnUiThread(returnRes); } } Here's the Adapter associated... public class SongsAdapter extends SimpleAdapter{ static List<HashMap<String,String>> songsList; Context context; LayoutInflater inflater; public SongsAdapter(Context context,List<HashMap<String,String>> imgListWeb,int layout,String[] from,int[] to,LayoutInflater inflater) { super(context,songsList,layout,from,to); this.songsList=songsList; this.context=context; this.inflater=inflater; // TODO Auto-generated constructor stub } @Override public View getView(int postition,View convertView,ViewGroup parent)throws java.lang.OutOfMemoryError{ try { View v = ((LayoutInflater) inflater).inflate(R.layout.row,null); ImageView images=(ImageView)v.findViewById(R.id.image); TextView tvTitle=(TextView)v.findViewById(R.id.text1); TextView tvAlbum=(TextView)v.findViewById(R.id.text2); TextView tvArtist=(TextView)v.findViewById(R.id.text3); HashMap<String,String> songsHash=songsList.get(postition); String path=songsHash.get("path"); String title=songsHash.get("title"); String album=songsHash.get("album"); String artist=songsHash.get("artist"); String imgPath=path; final ImageView imageView = (ImageView) v.findViewById(R.id.image); AsyncImageLoaderv asyncImageLoader=new AsyncImageLoaderv(); Bitmap cachedImage = asyncImageLoader.loadDrawable(imgPath, new AsyncImageLoaderv.ImageCallback() { public void imageLoaded(Bitmap imageDrawable, String imageUrl) { imageView.setImageBitmap(imageDrawable); } }); imageView.setImageBitmap(cachedImage); tvTitle.setText(title); tvAlbum.setText(album); tvArtist.setText(artist); return v; } catch(Exception e){ Log.e("error",e.toString()); } return null; } public static Bitmap loadImageFromUrl(String url) { InputStream inputStream;Bitmap b; try { inputStream = (InputStream) new URL(url).getContent(); BitmapFactory.Options bpo= new BitmapFactory.Options(); bpo.inSampleSize=2; b=BitmapFactory.decodeStream(inputStream, null,bpo ); return b; } catch (IOException e) { throw new RuntimeException(e); } } } Here is what logcat is showing... 04-23 16:02:02.211: ERROR/completed(1450): completed 04-23 16:02:02.211: ERROR/paths values(1450): [] 04-23 16:02:02.211: DEBUG/*****(1450): handler 04-23 16:02:02.211: DEBUG/AndroidRuntime(1450): Shutting down VM 04-23 16:02:02.211: WARN/dalvikvm(1450): threadid=3: thread exiting with uncaught exception (group=0x4001aa28) 04-23 16:02:02.222: ERROR/AndroidRuntime(1450): Uncaught handler: thread main exiting due to uncaught exception 04-23 16:02:02.241: DEBUG/webObjectList(1450): webObjectList 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): java.lang.NullPointerException 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at com.stellent.gorinka.MusicListActivity$2.handleMessage(MusicListActivity.java:81) 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at android.os.Handler.dispatchMessage(Handler.java:99) 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at android.os.Looper.loop(Looper.java:123) 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at android.app.ActivityThread.main(ActivityThread.java:4203) 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at java.lang.reflect.Method.invokeNative(Native Method) 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at java.lang.reflect.Method.invoke(Method.java:521) 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 04-23 16:02:02.252: ERROR/AndroidRuntime(1450): at dalvik.system.NativeStart.main(Native Method) I have declared the getter and setter methods in a seperate claa named SongsList. Plz help me determine the problem...

    Read the article

  • How to parse xml string in iphone 2.0

    - by MaheshBabu
    Hi folks, I am getting information (id,name,address) in the form of xml string form the .net web server. i am using NSXMlparsing to parse this xml string in iphone os 4.0. Now i need to do the same application in iphone os 2.0. i found Nsxmlparsing delegate should work on 4.0 and later. Can any one please suggest which method is suitable to parse xml string and sample tutorial. Thank u in advance.

    Read the article

  • RegEx - How To Insert String Before File Extension

    - by st4ck0v3rfl0w
    Hi All, How would I insert "_thumb" into files that are being dyanmically generated. For example, I have a site that allows users to upload an image. The script takes the image, optimizes it and saves to file. How would I make it insert the string "_thumb" for the optimized image? I'm currently saving 1 version of the otpimized file. ch-1268312613-photo.jpg I want to save the original as the above string, but want to append, "_thumb" like the following string ch-1268312613-photo_thumb.jpg

    Read the article

  • Python string manipulation

    - by paradox
    I'm trying to split a string into a int list for further processing. But somehow I can't remove certain whitespaces in between elements of the list. The string x is supposed to have a length of 1000 instead of 1019. I tried reading the documentation for python and saw the function strip() for stripping whitespaces from strings. However, it only works for trailing and leading whitespaces. How should I go about removing these whitespaces and also how do I convert a str list to a int list? My code is as follows : import array x = """73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450""" y=[] for i in range(0,len(x)): #String is now in a string list if x[i]!='': y.append(x[i]) print(y[i]) print(len(x))

    Read the article

  • Replacing string literal values in Visual Studio project templates

    - by Daniel A. White
    I notice when I create a project template from an existing project in my solution, it does a semi-string replace to update references. However, it does not replace string literals. It does update my web.config file, but not code files. The project template: namespace MyTemplateProject { class MyClass { public string GetStringValue() { return "MyProjectTemplate"; } } } The generated code when used as a template: namespace MyActualNewProject { class MyClass { public string GetStringValue() { return "MyProjectTemplate"; } } } How can I instruct the template maker to replace "MyProjectTemplate" wih "MyActualNewProject"?

    Read the article

  • Java add leading zeros to a number....

    - by user69514
    I need to return a string in the form xxx-xxxx where xxx is a number and xxxx is another number, however when i have leading zeros they disappear. I'm trying number formatter, but it's not working. public String toString(){ NumberFormat nf3 = new DecimalFormat("#000"); NumberFormat nf4 = new DecimalFormat("#0000"); if( areaCode != 0) return nf3.format(areaCode) + "-" + nf3.format(exchangeCode) + "-" + nf4.format(number); else return exchangeCode + "-" + number; } } I figured it out: public String toString(){ NumberFormat nf3 = new DecimalFormat("000"); NumberFormat nf4 = new DecimalFormat("0000"); if( areaCode != 0) //myFormat.format(new Integer(someValue)); return nf3.format(new Integer(areaCode)) + "-" + nf3.format(new Integer(exchangeCode)) + "-" + nf4.format(new Integer(number)); else return nf3.format(new Integer(exchangeCode)) + "-" + nf4.format(new Integer(number)); }

    Read the article

  • Java printf using variable field size?

    - by paxdiablo
    I'm just trying to convert some C code over to Java and I'm having a little trouble with String.printf. In C, to get a specific width based on a variable, I can use: printf("Current index = %*d\n", sz, index); and it will format the integer to be a specific size based on sz. Trying: System.out.println(String.format("Current index = %*d\n", sz, index)); results in an error since it doesn't like the *. I currently have the following kludge: System.out.println(String.format("Current index = %" + sz + "d\n", index)); but I'm hoping there's a slightly better way, yes?

    Read the article

  • PHP How to create real hex values from a string

    - by Piet
    Hi, I have a string with hexvalues that I use with sha1() echo sha1("\x23\x9A\xB9\xCB\x28\x2D\xAF\x66\x23\x1D\xC5\xA4\xDF\x6B\xFB\xAE\x00\x00\x00\x01"); ab94fcedf2664edfb9b291f85d7f77f27f2f4a9d now I have another string with the same value only not hex. $string2=strtoupper("239ab9cb282daf66231dc5a4df6bfbae00000001"); I want to convert this string so that it is read as above and that the sha1-value is the same as above. echo sha1(do_something($string2)); ab94fcedf2664edfb9b291f85d7f77f27f2f4a9d Does anybody know how to convert a string to real hexvalues? I've tried with pack, sprinft, hexdec, but nothing worked (couldn't find typecasting in hex) Thanks

    Read the article

  • C# - Accesing to items for a collection inherited from List<string>

    - by Salvador
    I am trying to implement a new class inherited from List<string>, to load the contents from a text file to the items. using System.Collections.Generic; using System.IO; using System.Linq; public class ListExt: List<string> { string baseDirectory; public LoadFromFile(string FileName) { this._items = File.ReadAllLines(FileName).ToList();//does not work because _list is private } } but i dont knew how to load the lines into the _items property because is private. any suggestions?

    Read the article

  • Compile time string hashing

    - by Caspin
    I have read in few different places that using c++0x's new string literals it might be possible to compute a string's hash at compile time. However, no one seems to be ready to come out and say that it will be possible or how it would be done. Is this possible? What would the operator look like? I'm particularly interested use cases like this. void foo( const std::string& value ) { switch( std::hash(value) ) { case "one"_hash: one(); break; case "two"_hash: two(); break; /*many more cases*/ default: other(); break; } } Note: the compile time hash function doesn't have to look exactly as I've written it. I did my best to guess what the final solution would look like, but meta_hash<"string"_meta>::value could also be a viable solution.

    Read the article

  • Regex Query to get string value

    - by Alex
    Hi all, I am looking for a regex query that would allow me to retrieve a value from a string here are examples of my string: home.aspx?StudyID=0020101&aa=72 randompage.aspx?studyid=3023603&aa=40 myconfig.aspx?studyid=0021600&aa=40 I need to get the numerical value of the 'studyid' variable, please note that the name of the page will change so simply doing the substring and counting char spaces didn't work I unfortunately cannot use request.querystring method as this string is stored in the database and a select statement will be used for running this regex query Thanks

    Read the article

  • Select dynamic string has a different value when referenced in Where clause

    - by David
    I dynamically select a string built using another string. So, if string1='David Banner', then MyDynamicString should be 'DBanne' Select ... , Left( left((select top 1 strval from dbo.SPLIT(string1,' ')) //first word ,1) //first character + (select top 1 strval from dbo.SPLIT(string1,' ') //second word where strval not in (select top 1 strval from dbo.SPLIT(string1,' '))) ,6) //1st character of 1st word, followed by up to 5 characters of second word [MyDynamicString] ,... From table1 Join table2 on table1pkey=table2fkey Where MyDynamicString <> table2.someotherfield I know table2.someotherfield is not equal to the dynamic string. However, when I replace MyDynamicString in the Where clause with the full left(left(etc.. function, it works as expected. Can I not reference this string later in the query? Do I have to build it using the left(left(etc.. function each time in the where clause?

    Read the article

  • Avoiding improper std::string initialization with NULL const char* using g++

    - by pachanga
    A there any g++ options which can detect improper initialization of std::string with NULL const char*? I was in the process of turning some int fields into std::string ones, i.e: struct Foo { int id; Foo() : id(0) {} }; ...turned into: struct Foo { std::string id; Foo() : id(0) {} //oooops! }; I completely overlooked bad 'id' initialization with 0 and g++ gave me no warnings at all. This error was detected in the run time(std::string constructor threw an exception) but I'd really like to detect such stuff in the compile time. Is there any way?

    Read the article

  • How to use EntityFramework connection string for Elmah?

    - by Andrii Kovalchuk
    In ELMAH for logging errors to the database you can write: <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="EducoparkEntities"/> However, if I use EntityFramework, this doesn't work because the connection string for EF contains metadata as well: <add name="EducoparkEntities" connectionString="metadata=res://*/EducoparkData.csdl|res://*/EducoparkData.ssdl|res://*/EducoparkData.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=(Local);Initial Catalog=...;User Id=...;Password=...;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/> So, how can I use the EntityFramework connection string in Elmah?

    Read the article

  • Convert IDispatch* to a string?

    - by Rob
    I am converting an old VB COM object (which I didn't write) to C++ using ATL. One of the methods, according to the IDL, takes an IDispatch* as a parameter and the documentation and samples for this method claim that you can pass either a string (which is the progid of an object that will be created and used by the control) or an IDispatch* to an object that has already been created. How on earth do I implement this in ATL? For example, the IDL: [id(1)] HRESULT Test(IDispatch* obj); The samples (which are all JScript): obj.Test("foo.bar"); or var someObject = new ActiveXObject("foo.bar"); obj.Test(someObject); To make matters even more bizarre the actual VB code that implements this method actually declares the 'obj' parameter as a string! However, it all seems to work. Can you even pass a string to a COM method that takes an IDispatch*? If so, can I determine that the IDispatch* is actually a string in my C++ ATL code? Even better, if it's an IDispatch that implements a specific interface I will want to call methods on it, or instantiate an object if it's a string. Any ideas welcome!

    Read the article

  • c# regex split and extract multiple parts from a string

    - by nLL
    Hi, I am trying to extract some parts of the "Video:" line from below text. Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (300 00/1) - 14.93 (1000/67) Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\a.3gp': Metadata: major_brand : 3gp5 minor_version : 0 compatible_brands: 3gp5isom Duration: 00:00:45.82, start: 0.000000, bitrate: 357 kb/s Stream #0.0(und): Video: mpeg4, yuv420p, 352x276 [PAR 1:1 DAR 88:69], 344 kb /s, 14.93 fps, 14.93 tbr, 90k tbn, 30k tbc Stream #0.1(und): Audio: aac, 16000 Hz, mono, s16, 11 kb/s Stream #0.2(und): Data: mp4s / 0x7334706D, 0 kb/s Stream #0.3(und): Data: mp4s / 0x7334706D, 0 kb/s* This is an output from ffmpeg command line where i can get Video: part with private string ExtractVideoFormat(string rawInfo) { string v = string.Empty; Regex re = new Regex("[V|v]ideo:.*", RegexOptions.Compiled); Match m = re.Match(rawInfo); if (m.Success) { v = m.Value; } return v; } and result is mpeg4, yuv420p, 352x276 [PAR 1:1 DAR 88:69], 344 kb What i am trying to do is to somehow split that line and get mpeg4 yuv420p 352x276 [PAR 1:1 DAR 88:69] 344 kb assigned to diffrent string objects instead of single

    Read the article

  • ASP.Net MVC 2 Error Method not found: 'System .string

    - by Saravanan I M
    I converted my website from asp.net mvc 1.0 to 2.0. After converting that i am getting the following error in actionlink Method not found: 'System.String System.Web.Mvc.Html.LinkExtensions.RouteLink(System.Web.Mvc.HtmlHelper, System.String, System.Web.Routing.RouteValueDictionary, System.Collections.Generic.IDictionary`2<System.String,System.Object>)'. Line 102: <%var Signin = Html.Resource("globalResources, Signin"); %> Line 103: <% if (string.IsNullOrEmpty(Signin)) Signin = "Signin"; %> Line 104: <%= Html.ActionLink<AccountController>(cntrl => cntrl.LogOn(), Signin.ToString(), new { @class = "defaultmaster" })%> Line 105: | Line 106: <%var register = Html.Resource("globalResources, Register"); %> Source File: e:\Muchsocial\Sourcecode\Muchsocial\Views\Shared\Muchsocial.Master Line: 104

    Read the article

  • How to take URL and split/string to get URL variables in Flash AS3

    - by Leon
    So I have a URL that I need my Flash movie to extract variables from: example link: http://www.example.com/example_xml.php?aID=1234&bID=5678 I need to get the aID and the bID numbers. I'm able to get the full URL into a String via ExternalInterface var url:String = ExternalInterface.call("window.location.href.toString"); if (url) testField.text = url; Just unsure as how to manipulate the String to just get the 1234 and 5678 numbers. Appreciate any tips, links or help with this!

    Read the article

< Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >