Android File To String

Here’s an example of turning a file into a string, by reading it line by line File file = new File(path); InputStream inputStream = new FileInputStream(file); BufferedReader r = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder total = new StringBuilder(); String line; while ((line = r.readLine()) != null) { total.append(line); } Now “total” will contain the file in

Read More

Xcode Printing NSData to NSLog

In Xcode Object-C to print out NSData to NSLog you might run into rubbish output by just outputting the NSData NSLog(@”%@”, myData); And as output something like this: <3c3f786d 6c207665 7273696f etc… This is not rubbish, though it might look that way, this is correct behavior and is just in hex format. If you know

Read More

Xcode Object-C NSUrl to NSString

In Object-C to convert back and forth from NSUrl and NSString take a look at this example: NSString *urlstring = [NSString stringWithFormat:@”http://spacetech.dk”]; NSURL *url = [NSURL URLWithString:urlstring]; NSLog(@”url = %@”,url); This will first save a NSString, then create a NSUrl from the String, and last output the NSUrl in the log

VB.net String Compare Not Equal

To compare to string in VB.net like many other language you can’t just use the equal sign = You have to use the .equal() function Dim firstString As String = “test” Dim secondString As String = “test” If (firstString.Equals(secondString)) Then ‘ code End If Now to set this to not equal to you could simply use

Read More