Posts

Showing posts from August, 2015

android - Google Map Inside viewpager and a vertical scroll view not getting displayed in some devices -

Image
i have viewpager 5 fragments , 1 among them search fragment google map weired issue in device map displayed no problem in device(micromax aq 5000 kitkat) it's not getting displayed fragment <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/mainlayerr" android:orientation="vertical" > <scrollview android:layout_height="wrap_content" android:layout_width="match_parent" > <linearlayout android:id="@+id/ll_menulayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <autocompletetextview android:id="@+id/txtsearchh" android:layout_height

c++ - Read an ifstream word for word into char* -

just trying programming test fun. stipulates should read each word of file, 1 one. it hints might want use ifstream, won't let me use std::string , looks have use char* in c read line line & use strok() have multiple delimiters (white-space, quotes, brackets, etc). what c++ way - words 1 one - without using std::string ? first must make sure have memory allocated string (this part handled automatically std::string ). use normal input operator >> , separate on whitespace. don't forget free memory allocate (also handled automatically std::string ). lesson learned: use char pointers exercises these, otherwise use std::string .

RYTHM not working deployed on GAE server, works on local GAE server. (1) -

i configured rythm to: rythmengine engine = null; map<string, object> conf = new hashmap<string, object>(); conf.put("engine.file_write", false); engine = new rythmengine(conf); string body = engine.render("hello @who!", "kitty"); resp.getwriter().println("{ \"name\": \""+body+"\" }"); works great on local gae server, deploy on google server, file write error. assume configuration "engine.file_write" not changed false or changed default. why happening? there solution?

css - Nesting flex box -

i find flex box useful, , since discovered tempted use everywhere. question is practice nest flex-boxes? having lot of them , nested ones has impact on performance? in short yes see dip in performance around 10x still talking milliseconds here though. so wary of using lot of them because 1 change render speed 10ms 100ms lot of them in essence highly increase render time. plus there comparability browser's , inability play absolute positioning , block element's. for recommend using display:table , children display:table-cell & display:table-row . here example of use: .align-table { display: table; width: 100%; table-layout: fixed; } .t-align { display: table-cell; vertical-align: top; width: 100%; }

ajax - Why is php://input rejecting my large file uploads? -

i've been turing internet upside down in order chunked large file uploads work symfony2 application. in order simplify things i've made test program seperate rest of application. thing trying test if php://input can accept large file upload method described in article: http://www.webiny.com/blog/2012/05/07/webiny-file-upload-with-html5-and-ajax-using-php-streams/ the way understand if user uploads large video file 2gb+ take 2gb+ ram on server , method in article cuts down 4096 bit per concurrent uploader. (i unsure how test ram usage on localhost server) however when try upload large files browser waits second , 2 , posts 1kb videofile. i have set high values php.ini settings. here relevant part of php code: public function lastoppaction(request $request) { $videofilename = (string)$request->request->get("filnavn"); $inputhandler = fopen("php://input", "rb"); $filehandler = fopen("videoer\\myfile.tmp&quo

javascript - Not able to insert a map -

i find code allows city information. how can implement simple map https://developers.google.com/maps/documentation/javascript/examples/map-simple ? see map on app. function same write on code. <!doctype html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>reverse geocoding</title> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var geocoder; if (navigator.geolocation) { navigator.geolocation.getcurrentposition(successfunction, errorfunction); } function successfunction(position) { var lat = position.coords.latitude; var lng = position.coords.longitude; codelatlng(lat, lng) } function errorfunction(){ alert("geocoder fa

android - TextView ignoring EditText style on device -

i have textview apply edittext style it, follows: <textview android:id="@+id/textview1" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="click here" android:theme="@android:style/widget.edittext" android:singleline="true" android:layout_margintop="16dp" android:onclick="opendialog" android:clickable="true" android:textappearance="?android:attr/textappearancemedium" /> in design mode looks fine (api 22), on device (api16), textview doesn't have style of edittext. what missing? edit using api 19 or api 16 in design mode, textview style not same edittext. it's api-related. do need appcompat jar?

Grails remote control plugin - Spring Security Configuration -

whenever try use grails remote control plugin, following exception. groovyx.remote.remotecontrolexception: error sending command chain 'http://localhost:8080/******/grails-remote-control' [test] @ groovyx.remote.transport.http.httptransport.send(httptransport.groovy:65) [test] @ groovyx.remote.client.remotecontrol.sendcommandchain(remotecontrol.groovy:114) [test] @ groovyx.remote.client.remotecontrol.exec(remotecontrol.groovy:73) [test] @ groovyx.remote.client.remotecontrol.exec(remotecontrol.groovy:67) [test] @ cgw.login.abstractcgwgebspec.msg(abstractcgwgebspec.groovy:35) [test] @ cgw.login.abstractcgwgebspec.login cgw application(abstractcgwgebspec.groovy:25) [test] caused by: java.io.streamcorruptedexception: invalid stream header: 3c68746d [test] @ java.io.objectinputstream.readstreamheader(objectinputstream.java:782) [test] @ java.io.objectinputstream.(objectinputstream.java:279) [test] @ groovyx.remote.util.classloaderconfigurabl

wordpress - Having an archive page with categories and tags -

i'd have archive (alternative search) categories , tags listed on 1 page. possible? can't seem find information on it. title/archive search< browse category: cat 1, cat 2 etc. (something more specific) browse tags: tag 1, tag 2 etc. something maybe? <?php get_header(); ?> <div id="container"> <div id="content" role="main"> <?php the_post(); ?> <h1><?php the_title(); ?></h1> <?php get_search_form(); ?> <h2>browse month:</h2> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> <h2>browse category:</h2> <ul> <?php wp_list_categories(); ?> </ul> <h2>browse tags:</h2> <ul> <?php wp_tag_cloud(','); ?> </ul> </div><!-- #content --> </div><!-- #container --> <?php get_sid

How to get the current selected item position using TabLayout in Android Design Library -

i using android design library tablayout in how can current selected item tab position. viewpager pager = (viewpager) view.findviewbyid(r.id.pager); mypageradapter adapter = new mypageradapter(getchildfragmentmanager()); pager.setadapter(adapter); tablayout.setupwithviewpager(pager); as of version 22.2.1 of support library tablayout has method getselectedtabposition . source 1 | source 2

ios - An extra view appears in cell when pressing reorder dragger, why? -

Image
i have uitableview varying height, , when pressing reorder control, in cell view structure new view appears. not problem, height quite big, , overlaps, cell below. why view appears? how can rid of it? or prevent overlap other cells? this view part of reorder mechanism , can't removed. used hide cell content while drag screenshot view above tableview. if set cell clipstobounds yes, should prevent it's content overlapping other cells.

html - Change application direction using Phonegap or SAPUI5 -

i not able change app direction using (html dir="ltr"), after android device language has been changed arabic. how can change app direction ltr using phonegap or sapui5? that kind of not possible, reason : because if need build entire android app again , run in device. possible solution you can use navigator.language detect device language , based on can load different css , html .

c# - How to export all pages of gridview to excel without columns containing controls? -

i have gridview has 2 columns dropdownlist , upload control. trying export gridview excel , code works works export current view not pages. when try export pages data binding fails , code crashes. please if know way of getting pages exported excel/csv or without columns containing controls. <asp:imagebutton id="exportbtn" runat="server" imageurl="../images/excelicon.jpg" alt="export" width="40px" height="40px" style="border-width:0px" onclick="exportbtn_click" /> protected void exportbtn_click(object sender, imageclickeventargs e) { gv.columns[7].visible = false; gv.columns[8].visible = false; response.clearcontent(); response.appendheader("content-disposition", "attachment; filename=documents.xls"); response.contenttype = "application/excel"; gv.allowpaging = false; gv.databind(); stringwriter sw

codeigniter - having issues with Error Number: 1064 -

any time try access page created says: error number: 1064 you have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 3 select * (`_db_tb_article`) `article_id` = filename: c:\xampp\htdocs\gtech\__ghtec__$y$tem__core\database\db_driver.php line number: 330 this model <?php class article_model extends ci_model { function add() { $this->db->insert('article',$_post); if($this->db->_error_number()){ return $this->db->_error_number(); } } function update($article_id, $data_fields = null){ if($data_fields == null){ $this->db->where("article_id =".$article_id); $this->db->update('article',$_post); }else{ $this->db->where("article_id =".$article_id); $this->db->update('article',$data_fields); } $is_error = $this->db->_error_number();

java ee - Transient fields from Hibernate PersistentClass -

why isnt possible access transient fields (or fields annotated @transient) hibernates metadata api? shouldn't persistentclass#getproperties include fields of entity regardless of annotations or field modifications (because metadata layer)? a similar question be: why not possible turn screws hammer? simply, unnecessary hibernate store these information never use , never care of. if want dynamic access fields, hibernate mapping files wrong place them, should use java reflection .

vb.net - How to handle Async method that returns Void with WCF service on Windows Phone -

i've created client app on windows phone (8.0) consumes wcf service. i've added service project using add service reference.. want call methods asynchronously can't figure out how in vb. i've seen lot of c# examples understand somehow can't figure out in vb, since not of vb programmer. what create client this: client = new isscompanionappserviceclient("isscompanionapp") where "isscompanionapp" endpoint. can call method: client.getsecuritytokenasync(username, password) valid method in service. method doesn't return value. how can pass callback in method? service have event handlers defined like: getsecuritytokencompleted(object, getsecuritytokencompletedeventargs) how implement this? i've searched on web examples either not applicable or in c#... i hate answer own questions found solution after more searching! this code used solve problem: public shared sub login(byval username string, byval password string)

java - AWS EBS snapshot, is there a way to know if the EBS is currently being written to -

i making snap shot util can take snap shots of ebs. snapshots recommended take place while ebs not active(by aws), because if active while take snapshot, won't pick being written @ time of snapshot. i wondering if there way determine if ebs being written to, or ideas of how determine such thing. the concern whether or not volume being written when snapshot initiated. outside of instance, not able tell, unless attached instance stopped or not attached @ all. from within instance, can freeze filesystem make consistent. don't need freeze entire duration of creating snapshot, initiating it.

ansible - template task: write to root owned directory -

i want copy template generated file /etc/init.d folder. template task doesn't seem support sudo parameter. recommended way handle this? should copy temporary directory , move file with sudo? the playbook task looks shown below. ansible version 1.8.2 - name: copy init script template: src=template/optimus_api_service.sh dest=/etc/init.d/optimus-api mode=0755 force=yes owner=root group=root i have tested following playbook , works. my setup: the user vagrant on machine vm allowed execute commands password-free sudo . i created simple template , installed following playbook: --- - name: test template hosts: vm gather_facts: no remote_user: vagrant vars: bla: blub # variable used in template tasks: - name: copy init script sudo: yes # << have activate sudo sudo_user: root # << , provide user template: src=template/test.j2 dest=/opt/test mode=0755 force=yes owner=ro

javascript - How to properly return HTML when doing AJAX -

i new using ajax , not think doing things correctly. page work fine , intended not think getting result in proper way. have page loads , display table gets ajax call. sends in couple parameters pagination purposes gets correct records page on. javascript $(document).ready(function() { var offset = document.getelementbyid('offset').value; var sortdirection = ""; var sorttype = ""; if (document.getelementbyid('setsortname').value != ""){ sorttype = document.getelementbyid('setsortname').value; } if (document.getelementbyid('setsortdirection').value != ""){ var sortdirection = document.getelementbyid('setsortdirection').value; } $.get("ajaxdistributormanage.php", { offset: offset, sortdirection: sortdirection, sorttype: sorttype}, function(html) { $("#distributortable").append(html); var resort = true

How To drag images directly from Camera or Smartphone to C# app? -

i found script ( http://www.codeproject.com/articles/28209/outlook-drag-and-drop-in-c ) makes possible drag images c# application. (especially outlook) filedrop format used copy (drag) images hard disk c# app. works when images stored on hard disk, when try drag images directly storage card (from camera or smartphone (like samsung s3)) won't work. these drag formats i'm getting image(s): (0): "shell idlist array" (1): "filecontents" (2): "filegroupdescriptorw" (3): "wpd storage attributes" (4): "preferred dropeffect" (5): "wpd nse" (6): "wpd nse pnpdevicepath" (7): "wpd nse storagepuid" (8): "usingdefaultdragimage" (9): "dragimagebits" (10): "dragcontext" (11): "dragsourcehelperflags" (12): "inshelldragloop" (13): "isshowinglayered" (14): "dragwindow" (15): "iscomputingimage" (16): "dataobjectattributes"

java - Some Updates missing in my Eclipse or errors in source code -

my developer (freelancer) finished working on app , sent me source code folder. when loaded in eclipse (as wanted export signed apk google play store) lists around 1000 errors. wanted ask experienced opinion if there wrong exclipse (missing package update or something) or there wrong code sent or elements/ files missing? all errors like: error: error retrieving parent item: no recourse found matched given name "theme.app"... actionbaractivity cannot resolved type bitmapdescriptionfactory cannot resolved etc. 1020 in total.

Cordova Kiosk mode for android -

i want code cordova app in kiosk mode. have found this solution . but if add code getting error on create apk. c:\temp\ksl\platforms\android\cordova\node_modules\q\q.js:126 throw e; ^ error code 1 command: cmd args: /s /c "c:\temp\ksl\platforms\ adlew cdvbuilddebug -b c:\temp\ksl\platforms\android\build.gradle -dor aemon=true" error building 1 of platforms: error: c:\temp\ksl\platforms\andr a\build.bat: command failed exit code 1 may not have required environment or os build project error: c:\temp\ksl\platforms\android\cordova\build.bat: command failed code 1 @ childprocess.whendone (c:\users\ebay\appdata\roaming\npm\node_m dova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23) @ childprocess.emit (events.js:110:17) @ maybeclose (child_process.js:1015:16) @ process.childprocess._handle.onexit (child_process.js:1087:5) without code if got no error. thanks help this functionality inclu

android - Setting the layout of the swiped card in RecyclerView using ItemTouchHelper -

i created recyclerview , attached itemtouchhelper , can swipe items in list. problem is, when swipe item, separator (2dp high view) swipes - there seems empty layout below item. is there way change layout? or other ways handle it?

javascript - Sort an array of objects by property based on another array of reference IDs -

i have array of objects similar this: [ { ref: "ctb98", name: "joe" }, { ref: "htf76", name: "alice" }, { ref: "jhu90", name: "tom" }, { ref: "adf56", name: "mary" } ] and in array have exact order meant in, referenced ref property: ["jhu90", "htf76", "ctb98", "adf56"] i'd rearrange order of first array of objects, ref values on each object follow same order values in reference array above. i'm new computer science, select answer best explanation of technique. i think want create hash of objects indexed ref prevent o(n^2) time. this method let reorder in o(n) time @ cost of o(n) space. var arr = [{ ref: "ctb98", name: "joe" }, { ref: "htf76", name: "alice" }, { ref: "jhu90", name: &q

excel - VBA - print current file name in every row -

i have working macro loops through folder open files , important info columns of names "holder" , "cutting tool" , printing info 1 excel document, masterfile. i print file name in column 1 in every row until file closes every entry in columns 2 , 3, there file name entry in column 1, , in column 4. i have working prints name in first cell , final cell, example if column 2 had info in rows 1 thorugh 4, file name printed in first column in row 1 , row 4. need of rows in between cannot seem make work. ideas? section (5) deal printing columns 1 , 4. recent fix line startsht.cells((getlastrowincolumn(startsht, "c")), 1) = objfile.name prints file name last cell. full code: option explicit sub loopthroughdirectory() const row_header long = 10 dim objfso object dim objfolder object dim objfile object dim myfolder string dim startsht worksheet, ws worksheet dim wb workbook dim integer dim lastrow integer, erow

java - Managing a Process inside a Thread -

i'm creating graphical interface runs threads. each 1 of these threads launch java process manage vnc connection. want keep track of process lifecycle storing in variables of thread manages. finally, gui communicates thread know process status. here snippet of code: public class vncviewer extends thread{ private static final string cmd = "some command"; private process vnc; private boolean active = false ; public void run(){ try { launchvnc(); } catch (ioexception ex) { logger.getlogger(vncviewer.class.getname()).log(level.severe, null, ex); } catch (interruptedexception ex) { logger.getlogger(vncviewer.class.getname()).log(level.severe, null, ex); } } private void launchvnc() throws ioexception, interruptedexception{ if (condition){ vnc = runtime.getruntime().exec(cmd); active = true; while(vnc.isalive()){} //while process aliv

javascript - Why does the variable executes the window object right away and not store it instead? -

i understand what's happening code in variable not stored immediately, instead executed first before can called. example code can (in global scope): var alertme = alert("i\'m being executed stored called again, why?"); because storing result of calling function, not storing function. this after: var alertme = function () { alert("i\'m being executed stored called again, why?"); }; and when want call it: alertme();

akka - Is it possible to await for second response in Scala -

let's have actor a. expects receive message , once receives message sends 2 messages back. a extends actor { def receive: receive = { case m1 => context.sender ! m2 context.sender ! m3 } } and in actor want send message , await 2 responses. know that's easy 1 response in way like val task = ? m1 await.result(task, timeout) but i'm not sure whether possible 2 sequential messages. it important send 2 separate messages need await first of them in place. you can solve problem introducing intermediate actor in cases when need wait both messages. this actor this: class aggregationactor(aactor: actorref) extends actor { var awaitform2: option[m2] = none var awaitform3: option[m3] = none var originalsender: option[actorref] = none def receive: receive = { case m1 => // save sender originalsender = some(sender()) // proxy message aactor ! m1 case m2 => awaitform2 = some(m2)

ios - How to delay loading first View Controller? -

i want delay loading first view controller until function in appdelegate finished. function should ready data first view controller. now, first view loads without data should prepared function in appdelegate what recommend way or example? please. should maybe move code gets data ready viewcontrollers "viewdidload" method? this method gets called after view controller goes memory , elements accessible, before becomes visible. processing here have complete before content shows, , put methods things server etc. if processing takes long time, use spinner let user know something's happening, because nothing show until processing done, user might think hung.

How to plot function with parameter in R -

i plot function several times, each time changing parameter (a constant) in function. how can this? fun1 <- function(x, b) abs(x^2 - b^2) plot(fun1(b=0.1),-1, 1) plot(fun1(b=0.2),-1, 1, add=true) same approach generalized in for-loop : (b in c(0.1,0.2))curve(abs(x^2 - b^2),add=true,col='red')

ms access - about field update using function with case -

i'm trying update field value depending 2 string field using function if , case , function below: private function checkdati(tipotransazione string, tipovendita string) string dim r string r = "" if tipotransazione = "vendita" select case tipovendita case "armi" if me.txtmatricola = "" r = "matricola" if me.txtmodello = "" r = "modello" if me.txtcalibro = "" r = "calibro" if me.txttipoarma = "" r = "tipo arma" if me.txtfabrica = "" r = "fabbrica" case "vendita armi/munizioni" case "munizioni" end select end if if tipotransazione = "acquisto" select case tipovendita case "armi" if me.txtmatricola = "" r = "matricola" if me.txtmodello = "" r = "

perl - How can I print a table with multi-line strings using the Text::Table module? -

i using cpan text::table module. have table in script , values multi-line strings. using rule print table. my code follows: #!/usr/bin/perl5.14.1 use findbin; use lib "$findbin::bin/mylib/text-aligner-0.12/lib/"; use lib "$findbin::bin/mylib/text-table-1.130/lib/"; use text::table; $tb = text::table->new(\'| ', "", \' | ', "field ", \'| ', "length ", \'| ', "comment ", \' |'); @aoa = ( [ 1, "foo", "20", "foo" ], [ 2, "bar", "35", "bar\nbar" ], [ 3, "tze", "10", "tze\ntze" ], ); $tb->load(@aoa); $rule = $tb->rule(qw/- /); @arr = $tb->body; print $rule, $tb->title, $rule; (@arr) { print $_ . $rule; } however when run following: |---|-------|--------|----------| | | field | length | comment | |---|-------|--------|----------| | 1 | foo | 20 | foo |

creating a dynamic html select option with perl -

the default selected value database not displayed, checked html , not show selected value. can give me insight on went wrong. thanks $selected_val = 'selected'; print "<select>"; if ($auto_flag eq 'y'){ $selected_val = 'selected'; }else{ $selected_val = ''; } if ($auto_flag eq 'n'){ $selected_val = 'selected'; }else{ $selected_val = ''; } print "<option value=\"y\" $selected_val >yes</option>"; print "<option value=\"n\" $selected_val >no</option>"; print "</select>"; you should using separate variable names y/n my $selected_y = ''; $selected_n = ''; if ($auto_flag eq 'y'){ $selected_y = 'selected'; } elsif ($auto_flag eq 'n'){ $selected_n = 'selected'; } print "<option value=\"y\" $selected_y >yes&

java - How do I define constants that must be overridden inside an interface? -

to create kits players can choose, have made interface: public interface kit {} and have implemented each kit: public class ninja implements kit {} now, want set constants related class, not instance. want these static across implementations of interface, , want each implementation override them. try #1: public interface kit { string display_name; // blank final field display_name may not have been initialized } try #2: public interface kit { static string getdisplayname(); // illegal modifier interface method getdisplayname; public & abstract permitted } an interface can not hold data way class can hold field. if not want kit instantiated, want abstract class. see them interface can have implementation , fields. note, please read further clarfication: read more so want in have abstract class in background, not interface. how look? public abstract class kit { protected final string name = "foo"; public string

cassandra - New Datastax driver for Tableau is not working -

trying run tableau on top of dse 4.7. fails. can't in worksheet or preview data. error: "missing eof @ 'tablename_i_try_to_query' " what right way fix it? so i've resolved it. when setup datasource tableau, have specify cluster, database , table (a.k.a. column family). specified cf/table ' tablename_i_try_to_query ' , dragged pane on right. specified database. didn't work. tableau generated query without specifying database. removed table pane , put again. tableau started generate correct query database.tablename_i_try_to_query

oracle - PL/SQL assinging values to a variable using cursor columns -

i trying take statistics against emp table, create table & rows inserted given below. trying develop store procedure columns particular table oracle all_tab_columns & generate statistics. the pl/sql block of code given below compiling not returning records when run it. can please let me know might getting wrong - `is "distinct_cnt := 'select count(distinct (' || table_rec.column_name || ')) from' || table_rec.table_name;"` a correct way of assigning result variable. create table emp( empno number(4,0), ename varchar2(10), job varchar2(9), mgr number(4,0), hiredate date, sal number(7,2), comm number(7,2), deptno number(2,0) ) insert emp values( 7839, 'king', 'president', null, to_date('17-11-1981','dd-mm-yyyy'), 5000, null, 10); insert emp values( 7698, 'blake', 'manager', 7839, to_date('1-5-1981','dd-mm-yyyy'), 2850, null, 30); insert emp values(

Google BigQuery Optimization Strategies -

i querying data google analytics premium using google bigquery. @ moment, have 1 single query use calculate metrics (like total visits or conversion rate). query contains several nested join clauses , nested selects. while querying 1 table getting error: error: resources exceeded during query execution. using group each , join each not seem solve issue. one solution adopted in future involves extracting relevant data needed query , exporting separate table (which queried). strategy works in principle, have working prototype it. however, explore additional optimization strategies query work on original table. in presentation you might paying bigquery of them suggested, namely: narrowing scan (already doing it) using query cache (does not apply) the book "google bigquery analytics" mentions adjusting query features, namely: group clauses generating large number of distinct groups (already did this) aggregation functions requiring memory proportional n

java multithreading in virtual Multicore single cpu vs multiple physical core cpus -

here use case of general java multithreading implementation: i have 1 cpu 4 virtual cores. i have 4 cpus 4 physical cores. which hardware should choose efficiently implement multithreaded application. far know, number of cores in cpu(virtual/physical) abstracted jvm operating system , jvm cannot differentiate between virtual/physical cores. however, hardware configuration should more efficient between 2 above mentioned options?

android - How do I link child fragments to the MainActivity? -

i'm building simple nba app since i'm new this. the mainactivity has listview 2 items. western teams , eastern teams. when user taps on item, shows teams of conference. these teams stored array items in strings.xml file. here mainactivity: public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); if (savedinstancestate == null) { getsupportfragmentmanager().begintransaction() .add(r.id.container, new placeholderfragment()) .commit(); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on hom

java - How to write only once to file from a thread? -

i want write end of file every time file modified , i'm using code : public class main { public static final string directory_to_watch = "d:\\test"; public static void main(string[] args) { path towatch = paths.get(directory_to_watch); if (towatch == null) { throw new unsupportedoperationexception(); } try { watchservice mywatcher = towatch.getfilesystem().newwatchservice(); filewatcher filewatcher = new filewatcher(mywatcher); thread t = new thread(filewatcher, "filewatcher"); t.start(); towatch.register(mywatcher, standardwatcheventkinds.entry_modify); t.join(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (interruptedexception e) { // todo auto-generated catch block e.printstacktrace(); } } } and thread clas