Posts

android - Creating File With String Object -

im writing socket program send , receive strings. im trying build file using received strings sending other side. done text files in others such image file doesn't work , when complete, image not open! in receiver: file = new file(dir,filename); fout = new fileoutputstream(file); dos = new dataoutputstream(fout); and when msg received: dos.write(msg.getbytes("utf-8")); in sender: file file = new file(filepath); inputstream = new fileinputstream(file); inputstreamreader isr = new inputstreamreader(is); ... isr.read(inputbuffer); i have tried solution problem didn't fixed: changing utf-8 iso-8859-1 using output stream writer instead of data output stream. trying smaller pictures text file. bytearrayoutputstream useful converting bitmap byte array. after then, using bitmapfactory, decodebytearray converting byte bitmap.

sql - How to link these two tables with the entity relationship model? -

if have 2 entities, "courses" , "course_offerings", , both have key called "course number" , how relate these 2 entities? relationship table not make sense because mapping same course number same course number, redundant. leaving them unlinked seems wrong. correct way er model? what er diagram like?

javascript - Flip toggle switch (jQuery) on change not firing -

i need fire event (which sends post data external script) when state of toggle switch changes, cannot basic example work... can please tell me doing wrong? html: <label for="flipswitch">option:</label> <select name="flipswitch" id="flipswitch" data-role="slider"> <option value="off">off</option> <option value="on">on</option> </select>` javascript (in <head> section): <script> $('#flipswitch').change(function(){ console.log("flipswitch"); }); </script> the code works me. sure you're looking @ console output? have code in $('document').ready(function() { )};

java - Replace backslash with forward slash -

this question has answer here: string not replacing characters 4 answers how replace backward slash forward slash using java? 3 answers i have following path: com/teama/merc/test/restest , want convert this: com\teama\merc\test\restest i trying append above path path: c:\users\toby\git\mercury\mercury\ str.replace('/', '\\'); when append both of strings together, output: c:\users\toby\git\mercury\mercury\com/teama/merc/test/restest here code in question: string home = system.getproperty("user.dir"); path.replace('/', '\\'); system.out.println(path); string folder = home + file.separatorchar + path; system.out.println(folder); file file = new file(folder); if(file.isdirectory()) { system...

java - Read from file inside Eclipse Project -

Image
i want make application splits big text file inside inputfolder several small xml files put inside outputfolder . this project outline: the following code works fine when comes getting file outside folder, when modified read folder inside project, gave me error: exception in thread "main" java.lang.nullpointerexception @ com.zakaria.cut.xmlcutter.cut(xmlcutter.java:45) @ com.zakaria.cut.main.main(main.java:8) [xmlcutter.java] package com.zakaria.cut; import java.io.bufferedreader; import java.io.file; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstreamreader; import java.io.outputstreamwriter; import java.text.messageformat; import java.util.logging.consolehandler; import java.util.logging.handler; import java.util.logging.level; import java.util.logging.logger; public class xmlcutter { private static final string output_file_name = "/file"; //private static string user_home = ...

java - Openfire VOIP Client, How To Use Media Proxy -

i developed voip app on android device. lacks of acrossing wlan capability. 1 udp connection established between 2 client phone in same lan. 2 phone client communicated via ipv4 address directly. i'm wandering how talk each other on wlan? maybe stay behind firewall. talked openfire has media proxy functionality agent transfer data. cannot find example of feature. please give me advice? much. sincerely. i assume have implemented jingle client. in order make work should make sure that: openfire (acting media proxy well) running on computer public ip, each client behind nat can "talk" it your client media engine support symmetric rtp to enable media proxy in openfire simple going openfire server web console (usually @ openfirehost:9090/index.jsp), select tab "media services", set option "enabled" @ "media proxy settings" , click on "save settings". ps: openfire version 3.9.1

Javascript undefined, truthy vs typeof operator -

considering following code: //the var test has not been declared yet console.log((typeof test)); // "undefined" console.log(test); //"uncaught referenceerror: test not defined" why second console.log statement throw referenceerror , first displays undefined. because test undefined. in first console.log you're asking system tell type of variable. looks through current scope chain find reference variable may infer type. when doesn't find variable, receives undefined primitive. has type, i'm sure you've guessed, of undefined . the second time you're asking print out value of undefined variable. since variable not defined (there no reference in current scope chain), error you're trying access data doesn't exist, not infer type.