Wednesday, 15 September 2010

javascript - Online game with THREE.js, physijs and Node.js -



javascript - Online game with THREE.js, physijs and Node.js -

i'm trying create simple web online game using physijs , node.js

i found related source here (https://github.com/jjoe64/nodejs-physijs)

and below basic server-side code want use.

'use strict'; var 3 = require('./libs/three.js'); var ammo = require('./libs/ammo.js'); var physijs = require('./libs/physi.js')(three, ammo); ///////////////// // game var initscene, render, renderer, scene, camera, box_falling; initscene = function() { scene = new physijs.scene; // box box_falling = new physijs.boxmesh( new three.cubegeometry( 5, 5, 5 ), new three.meshbasicmaterial({ color: 0x888888 }) ); scene.add( box_falling ); // box var box = new physijs.boxmesh( new three.cubegeometry( 5, 5, 5 ), new three.meshbasicmaterial({ color: 0x880088 }), 0 ); box.position.y = -20; scene.add( box ); settimeout( render, 200 ); }; render = function() { scene.simulate(); // run physics settimeout( render, 200 ); }; ////////////////// // web socket var io = require('socket.io').listen(8088); (function() { io.sockets.on('connection', function (socket) { console.log('client conneted'); }); // start physijs scene initscene(); })();

the problem is, beginner of node.js , socket.io, not know how import scene server-side code client's viewport. there client-side sample code of this? or how can emit scene info server client using sockets? how can display them?

you should have physics beingness calculated on server side , client side in synchronizedream way, , render scene date on client side. take @ source ironbane.

javascript node.js three.js physijs

javascript - PHPExcel - Render HTML markups on output -



javascript - PHPExcel - Render HTML markups on output -

in site have several forms using ckeditor store it's data. when export content, in excel can see markups on document. there easy way convert \n or somehow have phpexcel recognize them breaks?

i tried changing export type excel2007 thinking maybe excel render html markup, when switch types study crashes. im sticking excel5.

any help appreciated.

<?php /** phpexcel */ require_once '/excelphp/classes/phpexcel.php'; // create new phpexcel object $objphpexcel = new phpexcel(); $rows=2; $sheet=$objphpexcel->getactivesheet(); // set properties $objphpexcel->getproperties()->setcreator("maarten balliauw") ->setlastmodifiedby("maarten balliauw") ->settitle("office 2007 xlsx test document") ->setsubject("office 2007 xlsx test document") ->setdescription("test document office 2007 xlsx, generated using php classes.") ->setkeywords("office 2007 openxml php") ->setcategory("test result file"); //this hard coded *non dynamic* cell formatting $sheet->getcolumndimension('a')->setwidth(5); $sheet->getcolumndimension('b')->setwidth(15); $sheet->getcolumndimension('c')->setwidth(50); $sheet->getcolumndimension('d')->setwidth(50); $sheet->getsheetview()->setzoomscale(90); $sheet->getstyle('a:d') ->getalignment()->setvertical(phpexcel_style_alignment::vertical_center); //font setting back upwards grouping title. $support_team = array('font'=> array('bold'=> true,'color' => array('rgb' => '4d4d4d'),'size' => 22,'name' => 'arial'),'alignment' => array('horizontal' => phpexcel_style_alignment::horizontal_center,'vertical' => phpexcel_style_alignment::vertical_center),); //font settings header cells only. $headers = array('font'=> array('bold'=> true,'color' => array('rgb' => '4d4d4d'),'size' => 12,'name' => 'arial'),'alignment' => array('horizontal' => phpexcel_style_alignment::horizontal_center,'vertical' => phpexcel_style_alignment::vertical_center),); //border settings $borders = array('borders' => array('inside'=> array('style' => phpexcel_style_border::border_thin,'color' => array('argb' => '717171')),'outline' => array('style' => phpexcel_style_border::border_thin,'color' => array('argb' => '717171')))); // sql database connections $db = mysql_connect("localhost", "imc_coe2", "imc123"); mysql_select_db("imc_coe2",$db); $sql="select client, team_name,support_team_prime,prime_comments,support_team_backup,backup_comments,escalation1,escalation1_comments,escalation2,escalation2_comments,escalation3,escalation3_comments,escalation4,escalation4_comments,note tbl_address order team_name"; $result=mysql_query($sql); $numrows=mysql_num_rows($result); if ($numrows>0) { while($data=mysql_fetch_array($result)) { //cell merging $sheet ->mergecells('b'.$rows.':d'.$rows) ->mergecells('b'.($rows+2).':d'.($rows+2)) ->mergecells('b'.($rows+5).':d'.($rows+5)) ->mergecells('b'.($rows+10).':d'.($rows+10)) ->mergecells('c'.($rows+1).':d'.($rows+1)) ->mergecells('b'.($rows+11).':d'.($rows+11)); // add together info $objphpexcel->setactivesheetindex(0) ->setcellvalue('b'.($rows+1), 'client:') ->setcellvalue('b'.($rows+2), 'support grouping contacts') ->setcellvalue('b'.($rows+3), 'prime:') ->setcellvalue('b'.($rows+4), 'backup:') ->setcellvalue('b'.($rows+5), 'escalations') ->setcellvalue('b'.($rows+6), 'escalation 1:') ->setcellvalue('b'.($rows+7), 'escalation 2:') ->setcellvalue('b'.($rows+8), 'escalation 3:') ->setcellvalue('b'.($rows+9), 'escalation 4:') ->setcellvalue('b'.($rows+10), 'notes'); //format hardcoded text $sheet->getstyle('b'.$rows)->applyfromarray($support_team); $sheet->getstyle('b'.($rows+2))->applyfromarray($headers); $sheet->getstyle('b'.($rows+5))->applyfromarray($headers); $sheet->getstyle('b'.($rows+10))->applyfromarray($headers); //row height adjustments $sheet->getrowdimension($rows+3)->setrowheight(60); $sheet->getrowdimension($rows+4)->setrowheight(60); $sheet->getrowdimension($rows+6)->setrowheight(60); $sheet->getrowdimension($rows+7)->setrowheight(60); $sheet->getrowdimension($rows+8)->setrowheight(60); $sheet->getrowdimension($rows+9)->setrowheight(60); $sheet->getrowdimension($rows+11)->setrowheight(100); //cell wraptext $sheet->getstyle('c'.($rows+1).':d'.($rows+1))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+3).':d'.($rows+3))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+4).':d'.($rows+4))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+6).':d'.($rows+6))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+7).':d'.($rows+7))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+8).':d'.($rows+8))->getalignment()->setwraptext(true); $sheet->getstyle('c'.($rows+9).':d'.($rows+9))->getalignment()->setwraptext(true); $sheet->getstyle('b'.($rows+11).':d'.($rows+11))->getalignment()->setwraptext(true); //background color on cells $sheet->getstyle('b'.$rows.':d'.$rows)->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ff9bc2e6'); $sheet->getstyle('b'.($rows+2).':d'.($rows+2))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ff9bc2e6'); $sheet->getstyle('b'.($rows+5).':d'.($rows+5))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ff9bc2e6'); $sheet->getstyle('b'.($rows+10).':d'.($rows+10))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ff9bc2e6'); $sheet->getstyle('b'.($rows+1))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+3))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+4))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+6))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+7))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+8))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); $sheet->getstyle('b'.($rows+9))->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setargb('ffe6f1fa'); //border range $sheet->getstyle('b'.$rows.':d'.($rows+11))->applyfromarray($borders); //this section actual info imported sql database *don't touch* $objphpexcel->setactivesheetindex(0) ->setcellvalue('c'.($rows+1), utf8_encode($data['client'])) //this give cell c2. ->setcellvalue('b'.$rows, utf8_encode($data['team_name'])) // give cell b2 ->setcellvalue('c'.($rows+3), utf8_encode($data['support_team_prime'])) //this give c5 ->setcellvalue('d'.($rows+3), utf8_encode($data['prime_comments'])) // give d5 ->setcellvalue('c'.($rows+4), utf8_encode($data['support_team_backup'])) //this give c6 ->setcellvalue('d'.($rows+4), utf8_encode($data['backup_comments'])) //this give d6 ->setcellvalue('c'.($rows+6), utf8_encode($data['escalation1']))//this give c8 ->setcellvalue('d'.($rows+6), utf8_encode($data['escalation1_comments']))//this give d8 ->setcellvalue('c'.($rows+7), utf8_encode($data['escalation2']))//this give c9 ->setcellvalue('d'.($rows+7), utf8_encode($data['escalation2_comments']))//this give d9 ->setcellvalue('c'.($rows+8), utf8_encode($data['escalation3']))//this give c10 ->setcellvalue('d'.($rows+8), utf8_encode($data['escalation3_comments']))//this give d10 ->setcellvalue('c'.($rows+9), utf8_encode($data['escalation4']))//this give c11 ->setcellvalue('d'.($rows+9), utf8_encode($data['escalation4_comments']))//this give d11 ->setcellvalue('b'.($rows+11), utf8_encode($data['note'])); //this give b13 $rows+=14; } } // rename sheet $sheet->settitle('directory tool total dump'); // set active sheet index first sheet, excel opens first sheet $objphpexcel->setactivesheetindex(0); // redirect output client’s web browser (excel5) ob_end_clean(); $objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5'); header('content-type: application/vnd.ms-excel'); $today=date("f.d.y"); $filename = "directory_export-$today.xls"; header("content-disposition: attachment; filename=$filename"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); $objwriter->save('php://output'); exit; ?>

ms excel has no concept of html markup within cell, it's string value.... storing value abc<br />def treated string containing abc<br />def , not 2 lines containing abc , def respectively. if want treated 2 lines need alter <br /> "\n". need set cell alignment wrap.

javascript php html phpexcel

c# - Secure Authentication cookie Asp.Net -



c# - Secure Authentication cookie Asp.Net -

i have 2 page p1.aspx(login page) , p2.aspx(redirect page), both configured ssl. in p1.aspx created authentication cookie "secure" property set "true" , added in response object of p1.aspx.

but when page redirected p2.aspx p1.aspx,the authentication cookie in p2.aspx request shows cookie's "secure" property "false". not getting why "secure" property set "false" in requests cookie.

if checking secure on server side, won't true, because browser doesn't send attribute back. if check in chrome devtools, can find cookie has secure = true.

here quote wiki:

besides name–value pair, servers can set these cookie attributes: cookie domain, path, expiration time or maximum age, secure flag , httponly flag. browsers not send cookie attributes server. send cookie’s name-value pair. cookie attributes used browsers determine when delete cookie, block cookie or whether send cookie (name-value pair) servers.

so it's totally fine don't secure attribute in request, , has in response when send it. browser don't send in each request, still utilize anyway, , if request wont https, browser won't utilize cookie

c# asp.net security authentication cookies

.net - QueryOver Selecting DateTime throws exception -



.net - QueryOver Selecting DateTime throws exception -

when seek select properties subquery (as in queryover: select columns subquery) of type datetime next exception:

the type system.datetime can not assigned property of type system.int32

the code looks this:

var subquery = queryover.of<model>().where(x => x.foreignkey == someid); mainquery.selectlist(s1 => s1.selectsubquery(subquery.select(x => x.changedate)).withalias(() => mainqueryalias.changedate) .select(...) //properties mainquery mainquery.transformusing(transformers.aliastobean<mainmodel>());

where changedate of type datetime.

the exception occurs in:

var expectresultlist = mainquery.list();

when remove changedate select-list works. other properties (like type int / string subquery can selected well. think must missing conversion somewhere have no clue where.

solution:

the problem was using same subquery more 1 times selecting different values of subquery:

s1.selectsubquery(subquery.select(smth.).withalias(some alias) .selectsubquery(subquery.select(smth. else).withalias(other alias)

however after executing 1 select, somehow next select statements utilize wrong type (from prevous query?!?) current query...

the solution set .clone before every select maintain query in default state:

s1.selectsubquery(subquery.clone().select(smth.).withalias(some alias) .selectsubquery(subquery.clone().select(smth. else).withalias(other alias)

the problem was using same subquery more 1 times selecting different values of subquery:

s1.selectsubquery(subquery.select(smth.) .withalias(some alias) .selectsubquery(subquery.select(smth. else).withalias(other alias)

however after executing 1 select, somehow next select statements utilize wrong type (from prevoius query?!?) current query...

the solution set .clone before every select maintain query in default state:

s1.selectsubquery(subquery.clone().select(smth.) .withalias(some alias) .selectsubquery(subquery.clone().select(smth. else).withalias(other alias)

lessons learned:

always utilize .clone() if want execute same query multiple times or create separate queries!

.net nhibernate queryover

c# - How to make Wix call function inside a DLL without errors? -



c# - How to make Wix call function inside a DLL without errors? -

my issue windows has issues accessing dll installtools.dll since i'm calling function within openexeurl

here dll content

using system; using system.collections.generic; using system.linq; using system.text; using microsoft.deployment.windowsinstaller; using system.configuration; using system.diagnostics; namespace installtools { public class installhelper { [customaction] public static actionresult openexeurl(session session) { seek { var exeurl = installtools.properties.settings.default.exeurl; // prepare process run processstartinfo start = new processstartinfo(); int exitcode = 0; // come in in command line arguments, come in after executable name //start.arguments = arguments; // come in executable run, including finish path start.filename = exeurl; // want show console window? start.windowstyle = processwindowstyle.maximized; start.createnowindow = true; // run external process & wait finish using (process proc = process.start(start)) { proc.waitforexit(); // retrieve app's exit code exitcode = proc.exitcode; } } grab (exception e) { var errormessage = "cannot open exe file ! error message: " + e.message; session.log(errormessage); } homecoming actionresult.success; } } }

the wix file content :

<?xml version="1.0" encoding="utf-8"?> <wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <product id="*" name="mysetup" language="1033" version="1.0.0.0" manufacturer="sofar" upgradecode="c151e7ab-b83a-445f-93b2-2ab7122ea34b"> <package installerversion="200" compressed="yes" installscope="permachine" /> <majorupgrade downgradeerrormessage="a newer version of [productname] installed." /> <mediatemplate /> <feature id="productfeature" title="mysetup" level="1"> <componentgroupref id="productcomponents" /> </feature> <binary id="installtools" sourcefile="$(var.solutiondir)installtools\bin\$(var.configuration)\installtools.dll"/> <binary id="notepadplus" sourcefile="c:\program files (x86)\notepad++\notepad++.exe"/> <customaction id="openexe" binarykey="installtools" dllentry="openexeurl" execute="deferred" impersonate="yes" /> <!--<customaction id="openexe" return="ignore" directory="programfilesfolder" execommand="c:\program files (x86)\notepad++\notepad++.exe" impersonate="yes" execute="deferred"/>--> <installexecutesequence> <custom action="openexe" before='installfinalize'/> </installexecutesequence> </product> <fragment> <directory id="targetdir" name="sourcedir"> <directory id="programfilesfolder"> <directory id="installfolder" name="mysetup" /> </directory> </directory> </fragment> <fragment> <directoryref id="installfolder"> <component id="myappfile"> <file source="$(var.myapplication.targetpath)" /> </component> </directoryref> <componentgroup id="productcomponents" directory="installfolder"> <!-- todo: remove comments around component element , componentref below in order add together resources installer. --> <!-- <component id="productcomponent"> --> <componentref id="myappfile" /> <!-- </component> --> </componentgroup> </fragment> </wix>

you can notice i'm calling dll building custom action , add together execution sequence.

<customaction id="openexe" binarykey="installtools" dllentry="openexeurl" execute="deferred" impersonate="yes" /> <!--<customaction id="openexe" return="ignore" directory="programfilesfolder" execommand="c:\program files (x86)\notepad++\notepad++.exe" impersonate="yes" execute="deferred"/>--> <installexecutesequence> <custom action="openexe" before='installfinalize'/> </installexecutesequence>

my issue when launch installer error shown in next screenshot.

could please advice ?

1) create customaction class public: public class installhelper.

2) create sure you're referencing right dll, should end *.ca.dll extension. bin folder has supposedly 2 dll files: installtools.dll, installtools.ca.dll.

c# visual-studio-2010 dll wix

windows - Find if Perl executable is portable -



windows - Find if Perl executable is portable -

i'm trying patch programme checked portable version of perl this:

use config; $is_portable = $config{userelocatableinc};

this not work on strawberry perl, , programme failing.

i using perl 5.20.1, 64-bit:

>perl -v:userelocatableinc userelocatableinc='undef';

what can find if current perl portable one, strawberry or not?

that's do. perl -v:userelocatableinc tell if been built utilize relative paths or not.

strawberry not built option, not portable. if need support, you'll have build yourself, though understand activestate's perl has hacks create portable.

i'd consider raising ticket strawberry guys , seeing if should add together alternative build.

windows perl environment-variables strawberry-perl

Android camera image to a custom folder is blank -



Android camera image to a custom folder is blank -

greetings i'm trying develop activity in app user captures image using photographic camera , save custom folder in gallery here code i'm using

public class camerafragment extends fragment { private static final string tag = "testcma"; private static final int request_date = 0; private static final int request_photo = 1; private photographic camera mcamera; private surfaceview msurfaceview; private view mprogresscontainer; outputstream outstream = null; string filename; private camera.shuttercallback mshuttercallback = new camera.shuttercallback() { public void onshutter() { // display progress indicator mprogresscontainer.setvisibility(view.visible); } }; private camera.picturecallback mjpegcallback = new camera.picturecallback() { public void onpicturetaken(byte[] data, photographic camera camera) { // create filename filename = system.currenttimemillis() + ".jpg"; // save jpeg info disk fileoutputstream os = null; boolean success = true; seek { if (isdir()) { } /* * os = getactivity().openfileoutput(filename, * context.mode_private); */// os.write(data); } grab (exception e) { log.e(tag, "error writing file " + filename, e); success = false; } { seek { if (os != null) os.close(); } grab (exception e) { log.e(tag, "error closing file " + filename, e); success = false; } } if (success) { intent = new intent(); i.putextra(constants.extra_photo_filename, filename); getactivity().setresult(activity.result_ok, i); } else { getactivity().setresult(activity.result_canceled); } getactivity().finish(); getactivity().finish(); } private boolean isdir() { // todo auto-generated method stub // file file = createimagefile(); final string appdirectoryname = "xyz"; final file imageroot = new file( environment .getexternalstoragepublicdirectory(environment.directory_pictures), appdirectoryname); boolean x = imageroot.mkdirs(); x = imageroot.isdirectory(); outputstream fout = null; file imagepath = new file(imageroot.getabsolutepath()); file file = new file(imagepath, "ge_" + filename); // file = new // file(filename); seek { fout = new fileoutputstream(file); } grab (filenotfoundexception e) { e.printstacktrace(); } seek { fout.flush(); fout.close(); } grab (ioexception e) { e.printstacktrace(); } contentvalues values = new contentvalues(); values.put(images.media.title, "title"); values.put(images.media.description, "descriptoin"); values.put(images.media.date_taken, system.currenttimemillis()); values.put(images.imagecolumns.bucket_id, file.tostring() .tolowercase(locale.us).hashcode()); values.put(images.imagecolumns.bucket_display_name, file .getname().tolowercase(locale.us)); values.put("_data", file.getabsolutepath()); contentresolver cr = getactivity().getcontentresolver(); cr.insert(mediastore.images.media.external_content_uri, values); // final file image = new file(imageroot,filename ); homecoming false; } }; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // todo auto-generated method stub view view = inflater.inflate(r.layout.fragment_pin_camera, container, false); mprogresscontainer = view .findviewbyid(r.id.pin_camera_progresscontainer); mprogresscontainer.setvisibility(view.invisible); imagebutton takepicbutton = (imagebutton) view .findviewbyid(r.id.camera_button); takepicbutton.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub if (mcamera != null) { mcamera.takepicture(mshuttercallback, null, mjpegcallback); } } }); msurfaceview = (surfaceview) view .findviewbyid(r.id.pin_camera_surfaceview); surfaceholder holder = msurfaceview.getholder(); holder.addcallback(new surfaceholder.callback() { public void surfacecreated(surfaceholder holder) { // tell photographic camera utilize surface preview area seek { if (mcamera != null) { mcamera.setpreviewdisplay(holder); } } grab (ioexception exception) { log.e(tag, "error setting preview display", exception); } } public void surfacedestroyed(surfaceholder holder) { // can no longer display on surface, stop // preview. if (mcamera != null) { mcamera.stoppreview(); } } public void surfacechanged(surfaceholder holder, int format, int w, int h) { if (mcamera == null) return; // surface has changed size; update photographic camera preview size camera.parameters parameters = mcamera.getparameters(); size s = getbestsupportedsize( parameters.getsupportedpreviewsizes(), w, h); // // reset // in // // next // section parameters.setpreviewsize(s.width, s.height); s = getbestsupportedsize(parameters.getsupportedpicturesizes(), w, h); parameters.setpicturesize(s.width, s.height); mcamera.setparameters(parameters); seek { mcamera.startpreview(); } grab (exception e) { log.e(tag, "could not start preview", e); mcamera.release(); mcamera = null; } } }); // homecoming view; } @targetapi(20) @override public void onresume() { super.onresume(); if (build.version.sdk_int >= build.version_codes.gingerbread) { mcamera = camera.open(0); } else { mcamera = camera.open(); } } @override public void onpause() { super.onpause(); if (mcamera != null) { mcamera.release(); mcamera = null; } } private size getbestsupportedsize(list<size> sizes, int width, int height) { size bestsize = sizes.get(0); int largestarea = bestsize.width * bestsize.height; (size s : sizes) { int area = s.width * s.height; if (area > largestarea) { bestsize = s; largestarea = area; } } homecoming bestsize; } private file createimagefile() throws ioexception { // create image file name string timestamp = system.currenttimemillis() + ""; filename = "jpeg_" + timestamp + "_"; string storagedir = environment .getexternalstoragepublicdirectory(environment.directory_pictures) + "/xyz"; file dir = new file(storagedir); dir.mkdir(); file image = new file(storagedir + "/" + filename + ".jpg"); // save file: path utilize action_view intents filename = image.getabsolutepath(); contentvalues values = new contentvalues(); values.put(images.media.title, "title"); values.put(images.media.description, "descriptoin"); values.put(images.media.date_taken, system.currenttimemillis()); values.put(images.imagecolumns.bucket_id, image.tostring().tolowercase(locale.us).hashcode()); values.put(images.imagecolumns.bucket_display_name, image.getname() .tolowercase(locale.us)); values.put("_data", image.getabsolutepath()); contentresolver cr = getactivity().getcontentresolver(); cr.insert(mediastore.images.media.external_content_uri, values); log.i(tag, "photo path = " + filename); homecoming image; } }

it captures image , creates folder , image file in image blank flat black, can help me that

you not saving jpeg buffer info onto file, creating directories within isdir , creating file there extension jpg fout = new fileoutputstream(file); not saving image contents

edit here how can save info file

string filename = system.currenttimemillis() + ".jpg"; file directory = new file(environment .getexternalstoragepublicdirectory(environment.directory_pictures), "xyz"); // save jpeg info disk boolean success = true; seek { if (!directory.isdirectory() && !directory.mkdirs()) { throw new ioexception("unable create directories path " + directory); } file file = new file(directory, "ge_" + filename); fileoutputstream fout = new fileoutputstream(file); fout.write(data); fout.close(); mediascannerconnection.scanfile(cameraactivity.this, new string[] {file.getabsolutepath()}, new string[]{"image/jpg"}, null); } grab (ioexception e) { e.printstacktrace(); }

android camera android-gallery