Posts

java - forward slash in file path causing issues. File contents are not read. Gives "The system cannot find the path specified." error -

how handle forward slash in file path. requirement read contents of csv file. giving string filename = "mynewfile.csv" converting / \ . operating system windows. using rad ide. using file.separator didn't help. giving me the system cannot find path specified. error. tried this: inputstream = sampleclass.class.getclassloader().getresourceasstream("mynewfile.csv"); bufferedreader br = new bufferedreader(new inputstreamreader(is)); and this: the moment try escape / \/ ide shows me compilation error invalid escape sequence (valid ones \b \t \n \f \r \" \' \\ ) tried moving file directly under project(moved out src folder) , changed code br = new bufferedreader(new filereader(csvfile)); still seeing the system cannot find file specified. error can please ??? sampleclass.class .getclassloader().getresourceasstream( "com/xyz/abc/" + mynewfile.csv); ...

c# - How to properly merge lambda-expressions with different parameters -

i have 2 expressions : expression<func<long, bool>> condition = x => x < max; // exp # 1 if (count > 0) { expression<func<int, bool>> limit = x => x > -1; // exp # 2 condition = expression.lambda<func<long, bool>>( expression.andalso(condition, limit), condition.parameters); } var comparator = condition.compile(); while (comparator(k++, n--)) { // } the following code compiles takes 1 parameter of type "long" combined lambda, how can pass 2 different parameters combined lambda? expression<func<long, bool>> condition = x => x < max; // exp # 1 expression<func<long, int, bool>> combined = null; if (count > 0) { expression<func<int, bool>> limit = x => x > -1; // exp # 2 combined = expression.lambda<func<long, int, bool>>( expression.and(condition.body, limit.body), new parameterexpression[] ...

java - Array List .get() not working correctly -

i'm implementing greedy algorithm solve knapsack problem, , keep running issue can't figure out. public void greedysort() { int curw = 0; collections.sort(sorted); for(int = 0; < sorted.size(); i++) { entry temp = sorted.get(i); system.out.println("index: " + temp.index + "ratio: " + temp.ratio); } system.out.println("sorted size: "+sorted.size()); while(sorted.size() > 0 && curw < maxw) { entry temp = sorted.get(0); if(curw + temp.weight <= maxw) { ret.add(temp); curw += temp.weight; } sorted.remove(0); } } when run the entry temp = sorted.get(0); i indexoutofboundsexception, though loop after collections.sort(sorted) iterate through "sorted" correctly , print out values in right order. doing wrong? also, if see errors algorithm design within code, let me know those. edit: added sorted.size println. prints 20, should. sorted array...

beautifulsoup - Beautiful Soup Scrape not showing properly -

i'm doing simple, , results not showing properly. website bed bath & beyond . i'm trying product totals per category. my script looks this. r = requests.get("http://www.bedbathandbeyond.com/store/category/bed-bath/bedding-accessories/10505/") soup = beautifulsoup(r.content) li = soup.find_all("li", {"class" : "listcount nopadleft"}) l in li: print(l.text) and outputting nothing, though know there text in elements. need inside 1 element, found when wasn't working find_all instead try , figure out going on. this html of scraping: <li class="listcount nopadleft"> <strong>showing&nbsp; 1 - 48 </strong> <span>of&nbsp;124&nbsp;product(s) </span> </li> any ideas why happening? try code (python 3): import urllib.request rq import bs4 url=rq.urlopen('http://www.bedbathandbeyond.com/store/category/bed-bath/bedding-accessories/10505/...

html - centering a border within a class -

this laughable question reason can't seem align these guys totally centered. reason border box seems to left , not sure why. can help... jsfiddle. http://jsfiddle.net/greggy_coding/b3k9lhfz/4/ the html , css <div class="container-bottom"> <a href="http://www.google.com" target="_blank" class="linkbutton">learn more</a> <h4><span></span>click find out more </h4> </div> body { background: #fff; } .container-bottom h4 { font-weight: 500; font-size : 16px ; text-align:center; color: #fff; margin-left : auto; margin-right : auto; } .linkbutton{ border: 2px solid #fff; padding: 10px 50px; width: 50px; border-radius: 30px; margin: auto; position: relative; } .container-bottom{ background-color: #000; width: 300px; height:20%; padding: 25px; position: relative; margin-left: auto ; margin...

ajax - Javascript: alternative to encodeURIComponent? -

i have div i'm using in wysiwyg editor, , when user done writing gets submitted using ajax post request. i've been running problem: anytime text contains "&" character cut off after it. spent way time looking @ server-side code, issue turned out on client side (the whole url encoding thing). looked how fix on javascript side, , came "encodeuricomponent". based on pages read (links below), best way url encoding (escape deprecated , encodeuri doesn't encode characters. when supposed use escape instead of encodeuri / encodeuricomponent? should use encodeuri or encodeuricomponent encoding urls? but encodeuricomponent isn't working. here's how used it: var wysiwyg = encodeuricomponent(document.getelementbyid("wysiwyg").innerhtml); the contents of div submitted (so know it's not ajax call), doesn't fix "&" characters, , haven't been able find alternatives on google or so. i've got few shots...

database - deleting certain rows with multiple tables T-SQL -

i have database multiple tables. want remove entries has column id value. there way in t-sql given there might tables might not have column id? you use dynamic sql create command delete records tables column 'id' in database: declare @idtodelete varchar(max) = '10' declare @sql nvarchar(max) = '' set @sql = ( select 'delete ' + object_name(c.object_id) + ' id = ' + @idtodelete + char(10) sys.columns c join sys.objects o on o.object_id = c.object_id join sys.schemas s on s.schema_id = o.schema_id , s.name = 'dbo' c.name = 'id' xml path('') ) print @sql exec sp_executesql @sql