How to repeat string “n” times in java? [duplicate]

How to repeat string “n” times in java? [duplicate]

This question already has an answer here: Simple way to repeat a String in java 29 answers I want to be able to repeat a string of text "n" times:Somet

Using a filesystem::path, how do you open a file in a cross-platform way?

Using a filesystem::path, how do you open a file in a cross-platform way?

Let's say you have used the new std::filesystem (or std::experimental::filesystem) code to hunt down a file. You have a path variable that contains the full pathname to this variable.How do you open that file?That may sound silly, but consi

How to convert string to int64_t?

How to convert string to int64_t?

How to convert program parameter from argv to int64_t? atoi() is suitable only for 32 bit integers. 1:A C99 conforming attempt.[edit] employed @R. correction// Note: Typical values of SCNd64 include "lld" and "ld".#include #include int64

A custom ostream

A custom ostream

I need some guidance or pointers understanding how to implement a custom ostream. My requirements are:A class with a 'First, does it worth deriving from ostream? What do I get by deriving from ostream? What if my class simply implements few

What does &(int) { 1 } mean in C++?

What does &(int) { 1 } mean in C++?

I saw this here and I don't know what it means:&(int) { 1 }I thought it was weird because it seems like invalid syntax. It's casting a block scope(?) with a random 1 in the middle (without a semi-colon) and taking the address. Doesn't make

prevent typing non ascii characters in a textbox

prevent typing non ascii characters in a textbox

Since I think people have encounter it lots of time before I did and there may be some standart solution.. Can anybody give any hint direction how to prevent a user from typing non ascii characters in a textbox. 1:I personally find tinke

Android - Using pipe between native and java apps

Android - Using pipe between native and java apps

I'm developing on SGS2 api v.16I have two applications: native and JavaFrom the native app I open a Unix pipe with mkfifo() function and write some string to it.And in the java app I'm trying to read the string, but somehow the app blocks a

QtQuick 2 Transparent Window Background

QtQuick 2 Transparent Window Background

I've been searching how to make the background of my QtQuick 2.0 application transparent.Most answers I've found use QtDeclarative which is ok for QtQuick 1.0 but not version 2.Finally I found an answer that I will post but I would like to

How do I export class functions, but not the entire class in a DLL

How do I export class functions, but not the entire class in a DLL

I have developed a Win32 DLL, providing the details below, and want to create a CLI/C++ wrapper for the functions Connnect and LogOut.I know that entire classes and functions can be exported from a DLL.class CClientLib{ public:CClientLib (v

undocumented CONVERT styles - datetime 23

undocumented CONVERT styles - datetime 23

Recently I stumbled upon CONVERT function style 23, which is very handy as it gives you DATE in format yyyy-mm-dd. The problem is that it's not documented in msdn! (link from SSMS help after F1 on CONVERT: http://msdn.microsoft.com/en-us/li

how to Read the certificates file from the PKCS7.p7b certificate file usind openssl?

how to Read the certificates file from the PKCS7.p7b certificate file usind openssl?

I am getting PKCS7 file (p7b). I want to read the content of the file and extract certificate in X509 structure.How can I access individual Certificate from the PKCS container using openssl library? 1:I've used the following program:#inc

Identifier list Vs Parameter type list in C

Identifier list Vs Parameter type list in C

6.7.6.3 Function declarators (including prototypes)This part of the standard deals with 'Identifier list' and 'Parameter type list'. First of all, function declaration (not definition) is same as the function prototype. Am I correct? If thi

Image Sharpening Using Laplacian Filter

Image Sharpening Using Laplacian Filter

I was trying to sharpening on some standard image from Gonzalez books. Below are some code that I have tried but it doesn't get closer to the results of the sharpened image.cvSmooth(grayImg, grayImg, CV_GAUSSIAN, 3, 0, 0, 0);IplImage* lapla

How to replace special characters with their equivalent (such as “ á ” for “ a”) in C#?

How to replace special characters with their equivalent (such as “ á ” for “ a”) in C#?

I need to get the Portuguese text content out of an Excel file and create an xml which is going to be used by an application that doesn't support characters such as "ç", "á", "é", and others. And I can't just remove the characters, but repl

Example program of Cython as Python to C Converter

Example program of Cython as Python to C Converter

I found here and here that one can use Cython to convert Python to C, but I cannot find any step-by-step example. Let's say I have a simple function:foo.pyxcdef void foo(double* x): x[0] = 0.0setup.pyfrom distutils.core import setupfrom C

Library for parsing arguments GNU-style? [closed]

Library for parsing arguments GNU-style? [closed]

I've noticed the basic 'style' of most GNU core applications whereby arguments are:--longoption--longoption=value or --longoption value-abcdefg (multiple options)-iuwww-data (option i, u = www-data)They follow the above style. I want to avo

linux mail < file.log has Content-Type: application/octet-stream (a noname attachment in Gmail)

linux mail < file.log has Content-Type: application/octet-stream (a noname attachment in Gmail)

I've been using mail -s "here is a log file" "[email protected]" Which used to come through with headers:User-Agent: Heirloom mailx 12.4 7/29/08MIME-Version: 1.0Content-Type: text/plain; charset=us-asciiContent-Transfer-Encoding: 7bitBut

Youtube data API : Get access to media stream and play (JAVA)

Youtube data API : Get access to media stream and play (JAVA)

I want to access a youtube video and play using my own media player. I am able to get the video properties (title, url etc..) using the youtube data API. Can I get access to the stream of the video and use my own Media Player (like the Andr

Is there a way to detect that TCP socket has been closed by the remote peer, without reading from it

Is there a way to detect that TCP socket has been closed by the remote peer, without reading from it

First, a little background to explain the motivation: I'm working on a very simple select()-based TCP "mirror proxy", that allows two firewalled clients to talk to each other indirectly. Both clients connect to this server, and as soon as

Making a Read instance in Haskell

Making a Read instance in Haskell

I have a data typedata Time = Time {hour :: Int, minute :: Int }for which i have defined the instance of Show as beinginstance Show Time where show (Time hour minute) = (if hour > 10

How to replace nth character of a string with another

How to replace nth character of a string with another

How could I replace nth character of a String with another one?func replace(myString:String, index:Int, newCharac:Character) -> String { // Write correct code here return modifiedString}For example, replace("House", 2, "r") should be

In C#, how to check whether a string contains an integer?

In C#, how to check whether a string contains an integer?

I just want to know, whether a String variable contains a parsable positive integer value. I do NOT want to parse the value right now. Currently I am doing:int parsedId;if ( (String.IsNullOrEmpty(myStringVariable) || (!uint.TryParse(m

What is the difference between slice() and substr() in JavaScript?

What is the difference between slice() and substr() in JavaScript?

Can I ask what the difference is between string object slice() and substr() in JavaScript? 1:They have different signatures, .slice() is:string.slice(beginIndex, endIndex)Whereas .substr() is:string.substr(beginIndex, length);So for exam

C++ stl stringstream direct buffer access

C++ stl stringstream direct buffer access

this should be pretty common yet I find it fascinating that I couldn't find any straight forward solution.Basically I read in a file over the network into a stringstream. This is the declaration:std::stringstream membuf(std::ios::in | std::

Oracle's lack of a Bit datatype for table columns

Oracle's lack of a Bit datatype for table columns

I work as a developer on a small development team, and something has annoyed me to the point where I have decided to act...Oracle does not support a Bit datatype - or indeed anything else that makes obvious sense in true/false scenarios. Un