Posts

java - Jar file can't write files to local machine -

i know java applets have bunch of restrictions can , cannot access, thought jars different. record, i'm new jar files , like. i have written gui data entry tool, , able write formatted data text file. works when program run eclipse. however, once packaged in jar file, can no longer write-to-file piece work. doesn't error out either. there's no single line of code share here, program allows user is: look @ data sheet transpose data text fields in gui click save , produce text file containing data in selected directory that last step runnable jar failing me. click save , dialog box shows , everything, when check output folder, no file produced. note: not have incorrect path--i've checked that. said above, works in eclipse. is there restriction i'm missing? ideally i'd able share executable file few others divvy data entry task. there format packaging program allow work? (i've spend long time on , make work in java) below actionlistener save...

android - Configuration change using Robolectric -

to retain asynctasks across configuration changes, use fragment-based solution setretaininstance(true), hosts each asynctask , calls listening activity, similar solution http://www.androiddesignpatterns.com/2013/04/retaining-objects-across-config-changes.html ultimately, purpose test asynctask's retention functionality throughout configuration changes using robolectric, need start setting actual configuration change correctly. however, seems can't mimic exact reference behavior occurs during configuration change. real app: when running real app, on configuration change, activity destroyed , recreated while fragment retained, seems working. can see checking references before , after configuration change (example references used below): real app, before: activity: abc fragment: xyz real app, after: activity: bca fragment: xyz (properly retained , reattached) case 1: when running recreate() on activity in robolectric test, however, activity doesn't se...

Batch File - Read from a text file with spaces -

i wrote batch file read text file located in specific path. loop reads text file located in folder. if same path had spaces loop can't read it. if wrap path in quotes still can't read it. path exist, checked multiple times, , confirmed loop works pathnames contain no spaces. is i'm doing wrong, or, limitation of batch loop? code: for /f "tokens=* delims=" %%x in (c:\users\someuser\virtualboxlog\log.txt) set read=%%x if path contained space example c:\users\someuser\virtualbox log\log.txt can't read text file, if wrap quotes , folder virtualbox log existed. the solution problem enclosing path in quotes: "c:\users\someuser\virtualbox log\log.txt" but problem rises: for interprets quotet string string, not filename. to work around this, use usebackq keyword: for /f "usebackq tokens=* delims=" %%x in ("c:\users\someuser\virtualbox log\log.txt") set read=%%x

How To Use android:largeHeap:true In API <= 10 in Android -

how use android:largeheap:true in androidmanifest.xml cin api level 10 , bellow ? defined in api 11 , above. that attribute did not exist prior api level 11, , there no documented , supported way of requesting large heap prior api level 11. also, note there no guarantee get large heap on api level 11+ devices.

largest palindrome product in java -

i have written code fourth question of euler project. the question is: palindromic number reads same both ways. largest palindrome made product of 2 2-digit numbers 9009 = 91 × 99. find largest palindrome made product of 2 3-digit numbers. here code: public class largestpalindromeproduct { private static int product;//integer palindrome number private static string palindrome;//string palindrome private static int largestpalindrome(){ for(int = 100; i<=999; i++){ for(int k = 100; k<=999; k++){ product = i*k; palindrome = integer.tostring(product); for(int j = 0; j<= palindrome.length()-1; j++){ if(palindrome.charat(j) == palindrome.length() - 1 - j){ return product; } } } } return product; } public static void main(string[] args) { int largestpalindrome = largestpalindrome(); system.out.println(largestpalindrome); } } this ...

python - Unzip my_file.zip pulled from s3 using boto -

i trying use boto open .zip file have in s3 . trying work data directly, want avoid creating temporary files. in [201]: import stringio in [202]: import boto in [203]: conn = boto.connect_s3() in [204]: my_bucket = conn.get_bucket('my_bucket') in [205]: my_list = [ele ele in my_bucket.list('my_file.zip')] in [206]: f = stringio.stringio() in [207]: my_list[0].get_file(f) in [208]: f.seek(0) if file not zipped use: my_content = my_list[0].get_contents_as_string() but since zipped, getting garbage. an answer question want (i borrowed bit of attempt it) using gzip , can't find using zip . tried using zipfilezipfile , read , extract , extractall methods don't seem want. you should python module gzip : https://docs.python.org/2/library/gzip.html you should able stringio gzip. . from boto.s3.connection import s3connection import gzip stringio import stringio s3conn = s3connection() # assuming .boto has been setup bucket = s3co...

How to put different color random dots in a rectangle separated by a diagonal (JAVA) -

my problem cant diagonal resize properly. if run code diagonal on wrong side , when expand vertically doesn't maintain perfect diagonal 1 corner another. below have code program , driver. import javax.swing.jframe; public class points { public static void main(string[] args) { jframe frame = new jframe("points"); frame.setdefaultcloseoperation(jframe.exit_on_close); pointspanel panel = new pointspanel(); frame.getcontentpane().add(panel); frame.pack(); frame.setvisible(true); } } here main program import javax.swing.jpanel; import java.awt.dimension; import java.awt.graphics; import java.util.random; import java.awt.color; import java.lang.math.*; public class pointspanel extends jpanel { private final int max_points = 20000; private final int length = 1; private int x,x1,y,y1; private random random; double slope,b,c,g; public pointspanel(){ random = new random(); setbackground(color.black); setpreferredsize(new dimension(...